This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 16, 2011, 9:06 AM
51 Posts

Default action edit/read database

  • Category: Other
  • Platform: Windows
  • Release: 8.5.1
  • Role:
  • Tags:
  • Replies: 2
 I have an Xpage with a data source (document1)
The default action for the database is "edit document" 
I would like to use a computed default action.
When the user has a role "reader" the document should be opened as a reader. 
When the user has the role "editor" it should be opened as "edit document" .
I don't know the javascript for this. 
Sep 16, 2011, 12:55 PM
5 Posts
Re: Default action edit/read database
Hi,
 
You can write a SSJS (Server Side Java Script) library function as below, and then include this script library into your relevant xpage or custom control.
 
/*
* Role Checking
* This function will check if the current user has the role that you pass to this function
* The return value of this function is either 'true' or 'false' 
*/
function checkCurrentUserRole(strRole){
 var x = context.getUser().getRoles().contains('[' + strRole + ']');
 return x;
 
PS: When you are passing strRole then pass it without the square brackets for example checkCurrentUserRole("Editor") etc.
 
 
Hope this helps, if you need anything else then let me know. 
 
Regards 
Neeraj 
Sep 19, 2011, 7:01 AM
51 Posts
Re: Default action edit/read database
 This function will return true or false.
In this specific case it has to return "openDocument" or "editDocument" I guess.
Now the problem is that even when I return openDocument, i can still edit this document . 
Any idea ? 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal