How can I hide records on a table based on the user's group?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 07:31 PM
I would like to hide certain records on the Requested Item (sc_req_item) table based on a user's group or role.
For example, if a user submits a "Request to Pull Email" Service Catalog request, a record on the sc_req_item will be created. I want these requests to be only visible to users in the groups "ITSS-MRS Security" and "ITSS-ECS E-Mail". I have created a beforeQuery Business Rule that runs on records with item = 'Request to Pull Email', but I am having trouble with the code in the advanced section of the business rule (the code should go something like this):
if (user.group == "ITSS-MRS Security" || user.group == "ITSS-ECS E-Mail" || user.role == "admin") {
visible = true
} else {
visible = false
}
How do I finish this code so that only those users can see the records?
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 07:40 PM
you need something like below in script
condition: !gs.getUser().isMemberOf('ITSS-MRS Security') && !gs.getUser().isMemberOf('ITSS-ECS E-Mail') && !gs.hasRole("admin")
script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.addEncodedQuery('cat_item!=xxxxxxxxxxsys_id of item');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 07:48 PM
I'm not sure I understand the second half of your response. Would the script look like this?
current.addEncodedQuery('cat_item!=xxxxxxxxxxsys_id of item');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 08:16 PM
current.addActiveQuery();
}
And, I think your condition will work to check the if current logged user belongs to specific group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2018 08:21 PM
hoping your have item = 'Request to Pull Email' in BR condition builder.