Xpages - How to prevent users from creating a new document if one already exists -


i'm working on notes database. want prevent user creating new document if there exists completed document from/by user. in notes classic form, have incorporated check in queryopen event (see code below) , works well. how can have similar event in xpages? lot anthony

if isnewdoc   mkey = evaluate("@name([cn]; @username)")   set db = session.currentdatabase   set view = db.getview("view-name")   view.autoupdate = false   set ve = view.getentrybykey(mkey)   if not (ve nothing)      messagebox "please note have document"      continue = false   else      continue = true   end if else   continue = true end if 

sessionscope allows store information relevant current browser session (often used capture user-specific information). many apps tend use along lines of inituser() function - @ http://xhelp.openntf.org, example, has initcurruser() in application ssjs library.

with kind of approach, run check when user first hits page in application, calling function in beforepageload event. can store result in sessionscope variable. know life of browser session whether user has created document or not. can hide create button or prevent access page or whatever based on sessionscope variable.

when create document during session, remember set sessionscope variable.

this better practice queryopen event of form, because instead of running everytime create or open document, runs once per session.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -