Limiting the users in displayed in 'Add Members' on a Visual Task Board (VTB)
Limiting the users in displayed in 'Add Members' on a Visual Task Board
Situation: We recently had a request to only display a specific set of users in the 'Add Members' drop down on a Visual Task Board.
Evaluation:
When selecting a Visual Task Board all active users are displayed in the drop down. Normally this would be a quick change to a reference qualifier on a relevant table (see Notes for tables used by VTB) so we need to build something a little different.
The trick here is to use your browser's developer tools (most modern browsers this is activated by pressing the F12 key) to determine how the page is querying the database for the list of users.
- Navigate to a Visual Task Board
- Select the User's tab
- In the Developer tools window, click the Network tab then select the trashcan to clear the data in the network window
- Select 'Add Members' in the Users pane on your visual task board and you should see a new entry appear in the network window.
Scrolling through this data, you will see a referrer label which is a link to your current visual task board. Note that the URL contains 'vtb.do' and 'angular.do?sysparm_type=ref_list_data'. This what we'll reference in the next few steps to tell ServiceNow that the browser is asking for the user list from a visual task board.
Solution:
The following steps will show you how to limit the 'Add Members' drop down to only display a chosen subset of users on all Visual task boards.
1. In Filter navigator, type sys_user.FILTER to open the Users table. From here, build a query with the conditions to limit the users you would like to appear in the Add Members drop down. Once your filter is accurate, right click on the filter and select copy query.
Your clipboard should contain something similar to: roles=itilactive=true
Keep this around as you'll be copying more things to your clipboard in the next few steps.
2. In your filter navigator, type Business Rules and select Business rules under System Definition.
- 1. Click New to create a new business rule
- Give this business rule a name that will make sense when you come back to it months from now such as 'Restrict VTB Add Members to ITIL users'
- On the When to run tab:
- 1. Set the When dropdown to Before and Check the Query box
- Check the Advanced checkbox in the top right and navigate to the Advanced tab that appears
- In the Advanced tab, set the condition box to:
gs.getSession().isInteractive() && gs.action != ''
This tells the Business rule to only run when there is an interactive session and action. In our case this is a user clicking the 'Add Members' dropdown. - Add the following in the Script box:
This script looks at that Referrer URL that we saw earlier in our Developer tools to contain vtb.do and is also looking that the URL contains 'angular.do?sys_parm=ref_list_data' which is the user selecting the 'Add Members' dropdown.
- Check the Advanced checkbox in the top right and navigate to the Advanced tab that appears
- Give this business rule a name that will make sense when you come back to it months from now such as 'Restrict VTB Add Members to ITIL users'
(function executeRule(current, previous /*null when async*/) {
//If the vtb page calls for a list of user records, restrict the records sent back to <add query contions here>
if ((gs.action.getGlideURI().toString()).indexOf('vtb.do') != -1 || (gs.action.getGlideURI().toString()).indexOf('angular.do?sysparm_type=ref_list_data') != -1) {
current.addEncodedQuery('<add encoded query here>');
}
})(current, previous);
Before saving, you'll need to update the <> portions of this script, first with comments on what function this script is performing and also to replace the with the sys_user encoded query from above.
Return to a visual task board to confirm that only the users in the select query are visible in the drop down.
Notes:
VTB associated tables:
- vtb_board_label
- vtb_board_member
- vtb_card
- vtb_card_history
- vtb_lane
- vtb_task
If your users cannot see any members to Visual task boards see this knowledge article.
Labels:
https://www.servicenow.com/community/now-platform-articles/limiting-the-users-in-displayed-in-add-members-on-a-visual-task/ta-p/2316753
