@UserRoles Replacement for Hiding/Showing Edit, Save, or Delete "Form" Button

Mindwatering Incorporated

Author: Tripp W Black

Created: 02/16/2011 at 12:29 AM

 

Category:
Notes Developer Tips
XPages

Issue:
@UserRoles doesn't seem to be a function available in XPages JavaScript.

Workaround:
var uRoles:Array = database.queryAccessRoles(session.getEffectiveUserName());
@IsMember("[admin]", uRoles)

one line version:
context.getUser().getRoles().contains('[admin]');

This could be part of the code whether to hide a Delete button for a document on a Custom Control.

The entire button might look like:
<xp:button value="Delete" id="btncontact4">
<xp:this.rendered><![CDATA[#{javascript:var uRoles:Array = database.queryAccessRoles(session.getEffectiveUserName());
!doccontact1.isNewNote() && !doccontact1.isEditable() && (@IsMember("[admin]", uRoles));

}]]></xp:this.rendered><xp:eventHandler event="onclick" submit="true"
refreshMode="complete" id="eventHandler4">
<xp:this.action>
<xp:deleteDocument name="$$PreviousPage"
message="Your document has been deleted.">
</xp:deleteDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>




previous page