Search code examples
xpagesdocumentxpages-ssjs

Xpages , Change document mode using Computed property menu button


I want to set the document mode onclick dynamically.

When I click a button, the onclick action is "Change Document Mode",In which we have 4 options to select.

  1. Toggle 2. Read Mode 3. Auto Edit and last is Edit Mode.

But Beside this the computed property button is provided, Below image can make the query more clear.

Edit mode computed option

In the computed property button it is allowed to write ssjs code,

So I am not getting that, what keyword should I return there for all the four option to be in working according to condition.

The sample code which I was trying to get the edit mode is:

var uid = context.getUrlParameter("documentId");
var doc:NotesDocument = database.getDocumentByUNID(uid);

if(doc.getItemValueString("$$disabled") != "true") {
     // want to return the Edit Mode 
     return "Edit Mode "
} else {
     // do nothing
     return false;
}

Any valuable suggestions would be appreciated.


Solution

  • You can see which value is set for a selected document mode if you switch to Source tab.

    enter image description here

    This is the list of the options and its internal values:

    Toggle ======> toggle  
    Read Mode ===> readOnly  
    Auto Edit ===> autoEdit  
    Edit Mode ===> edit  
    

    You would return "edit" in your code if you want to switch to Edit Mode for example.