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
 
  |