save - run script when xpages saving document -
the xpages contain save button. xpages contain internetaddres field. when user click save button, need check first on names.nsf - save success if internetaddress value not found in names.nsf view "($users)" - save fail if internetaddress value found in names.nsf view "($users)"
how write script that?
this lotusscript version of script:
set namesview = namesdb.getview( "($users)" ) set namesdoc = namesview.getdocumentbykey( lcase(doc.currentinternetaddress( 0 ) ), true ) if ( namesdoc nil ) '-- create new doc
how move on xpages?
the latest release of openntf domino api adds checkunique() method view class. takes 2 parameters, first beingness key check against view (e.g. string or list of strings), sec beingness current document. after all, if you're checking pre-existing document, don't want fail because finds document in view.
so assuming currentinternetaddress single value field, code be:
function continuewithvaliduser(namesdb, doc) { var success = false; seek { var view = namesdb.getview("($users)"); success = view.checkunique(doc.getitemvalue("currentinternetaddress"),doc); } grab (e) { print(e.message); } homecoming success; }
openntf domino api recycles handles domino objects, recycle() calls aren't needed.
save xpages
No comments:
Post a Comment