Script Solution to put Document in Edit Mode

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/11/2011 at 12:18 PM

 

Category:
Notes Developer Tips
XPages

Issue:
Change or set the Document state/mode via button or script in an XPage.
(Equivalent of @EditDocument on the web)

Solution:
context.setDocumentMode("edit");
to put the current document displayed into edit mode.
Other options are: readOnly, autoEdit, toggle.

To get the mode:
<datasource>.isEditable();
where <datasource> is the name of your document's datasource (e.g. doc1.isEditable();)


Example of visibility code for both a user role [staff] and a datasource xwp1:

var uRoles:Array = database.queryAccessRoles(session.getEffectiveUserName());
var editmode = xwp1.isEditable();
if(@IsMember("[staff]", uRoles) && editmode==false) {
true;
} else {
false;
}


previous page