One way to control visibility of text, buttons, fields, forms, views, and other design elements is through the use of roles. Using roles, you can manage the display of information or database functionality. For example, you can custom-tailor instructions for completing a form based on the user's role, where one paragraph is displayed to users assigned the "Employee" role and a different set of instructions is displayed for those assigned the "TeamLead" role. Roles can also be used to manage the display of action buttons, the visibility of database views, or the ability to access a controlled section on a document.
Hiding a field based on a user role is not a security feature. Users will still be able to view fields using the Document Properties dialog box. See Chapter 19, "Security," for additional information regarding document security.
How It Works
The @UserRoles function returns the current roles assigned to a given person. When added to the Hide paragraph when formula is true property section, you can manage the display of text, a field, or an action button, among others. Roles are created in the Access Control List (ACL) for the database, as illustrated in Figure 14.12.
Figure 14.12. The Roles section of the Access Control List
After the role is created, the role must be assigned to a person, server, or group. This is also accomplished in the Basics tab of the database ACL. See Chapter 19 for additional information pertaining to database security.
The @UserRoles function only works on server-based databases or local databases where the Enforce a consistent ACL across all replicas property has been enabled.
The following outlines how to use roles to manage the display of design elements and data.
First, create the roles for the database. Select the File > Database > Access Control menu options. You must have "Manager" level authority in order to change the ACL settings for the database. When the dialog is displayed, switch to tab 2 (left side). Click the Add button to define one or more roles for the database. Then switch to the Basics tab and assign the role(s) to a person, server, or group.
Create a design element, such as a button, field, or view. Open the properties dialog for the design element and locate the tab that contains the "Hide When" settings. This tab will contain a "window shade" icon on the tab. The location of this tab will vary based on the design element. Figure 14.13 depicts the property setting for a field, which is located on tab 6.
Figure 14.13. Set the "Hide When" formula based on a user's role
Select the Hide paragraph if formula is true option and insert the following formula. Be sure to replace the role with a valid role name (as illustrated in Figure 14.13). This first formula will hide the element if the user has the specified role.
@Contains (@UserRoles; "[ROLENAME]");
Conversely, to implement a formula that checks whether the user does not have a particular role, simply prefix the formula with an exclamation point "!". The exclamation point is a logical "Not" character.
!@Contains (@UserRoles; "[ROLENAME]");
Be sure to include the left and right brackets when referencing a role. These characters are required in order to reference the role.
Working with @DBColumn
An Introduction to the Lotus Domino Tool Suite
Getting Started with Designer
Navigating the Domino Designer Workspace
Domino Design Elements
An Introduction to Formula Language
An Introduction to LotusScript
Fundamentals of a Notes Application
Reference Library Applications
Design Enhancements Using LotusScript
Design Enhancements Using Formula Language
Miscellaneous Enhancements and Tips for Domino Databases
Application Deployment and Maintenance
Appendix A. Online Project Files and Sample Applications
Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?