Controlling Access to Individual Custom Menu Items and Toolbar Buttons

Normally, either full access or no access is granted to all of the menu items or toolbar buttons for a particular type of list. However, in the User Access sample application, custom entries in userAccess.xml, and code in the application, are used to control whether individual buttons and menu items appear.

This is done through additional access tags added underneath the standard menu and toolbar items. For instance, the following is the privilege access that controls whether the items for starting any business service are displayed:

<PrivilegeAccessSet name="Start Any Business Service"
            description="Grants access to a custom menu/toolbar for
                         starting any business service">
   <privileges>
       <privilege name="StartAnyBusinessService"></privilege>
   </privileges>

   <access name="CustomAccess">
      <access name="CustomMenuAccess">
         <access name="menu">
            <access name="WorkItemList">
                <access name="StartAnyBusinessService"></access>
            </access>
          </access>
          <access name="toolbar">
             <access name="WorkItemList">
                 <access name="StartAnyBusinessService"></access>
             </access>
           </access>
       </access>
   </access>
</PrivilegeAccessSet>

The entries for <access name="StartAnyBusinessService"></access> have been added where subordinate items normally do not appear.

Note: Note that the example here shows the custom access items being added directly to the userAccess.xml file, which is what you would do if you are customizing an undeployed application in your local development environment. If you were customizing an application that is deployed to a runtime node, you would use the Configuration Administrator— for more information, see Configuring User Access .

The other two user access sets that control access to the custom menu items and toolbar buttons (StartFilteredBusinessServices and StartRemainingBusinessServices) are similar.

Code in the following file controls whether or not the custom items are visible:

.../wccAccessSample/application/js/Application.js

In the postLoadInit function, the application subscribes to the renderComplete event of the work item list. When the work item list is initially displayed, the createCustomServicesMenu function in the same file is called. That function checks each of the custom settings to see if it has been granted through user access sets in userAccess.xml. For items that have not been granted, it deletes the corresponding custom menu item or toolbar button (comments inside the createCustomServicesMenu function provide more detail).