javascript - How to add a docID from one NotesDocument to another using Java Script -
i have lotus script add organization docid contactdoc , work fine achieve in java script
sub addcontactid(contact notesdocument, organisation notesdocument) contact.tmpidstring = organisation.docid(0) dim tmp variant tmp = |@setfield("contactorganisationids";@trim(@unique(contactorganisationids:tmpidstring)))| dim flag variant flag = evaluate(tmp,contact) dim item notesitem set item = contact.getfirstitem("tmpidstring") if not (item nothing) call item.remove end if end sub
reverse function:
sub removeorganisationidbyid(contactdocid string, organisation notesdocument) dim session new notessession dim currdb notesdatabase set currdb = session.currentdatabase dim contact notesdocument set contact = currdb.getdocumentbyunid(contactdocid) if contact nothing exit sub if organisation nothing exit sub dim contactorganisationids variant contactorganisationids = contact.contactorganisationids pos = arraygetindex(contactorganisationids, organisation.docid(0)) if not isnull(pos) contactorganisationids(pos) = "" call contact.replaceitemvalue("contactorganisationids",fulltrim(contactorganisationids)) call contact.save(true, false) end if end sub
the following ssjs function should it
function addcontactid(contact, organisation) { contact.replaceitemvalue("tmpidstring", organisation.getitemvaluestring("docid")); session.evaluate('field contactorganisationids := @trim(@unique(contactorganisationids:tmpidstring)); field tmpidstring := @deletefield; ""', contact); }
parameters contact
, organisation
have of type notesdocument
. don't forget save contact document sometime after calling function.
Comments
Post a Comment