- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2017 09:23 PM
How to hide application menu and module based on group.
I tried business rule
Table: Application Menu [sys_app_application] or Module[sys_app_module]
When: before
Query = true
if(gs.getUser().isMemberOf('Group A') )
{
current.addQuery('sys_id','!=','5212632ced4f5500b14f689a971ad873');//sys_id of the application
}
but not working for me.
ctomasi you can suggest me a better way.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 11:21 AM
Hey Ankit,
Say Chuck said, give roles to that modules/menus.
Or you can give role to that group and hide on that basis -
if(gs.getUser().isMemberOf('Group_name') && gs.getUser().hasRole('group_role'))
{
var car= current.addQuery('title','!=','Self-Service');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 11:21 AM
Hey Ankit,
Say Chuck said, give roles to that modules/menus.
Or you can give role to that group and hide on that basis -
if(gs.getUser().isMemberOf('Group_name') && gs.getUser().hasRole('group_role'))
{
var car= current.addQuery('title','!=','Self-Service');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 11:30 AM
Hey Nayan,
Thanks code working fine and i was facing issue because of cache.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 05:39 PM
Hi Nayan,
The code is not working for me. This business rule just appears very flaky.
Did you put your codes in the block of
(function executeRule(current, previous /*null when async*/) {
})(current, previous);
In the When to run tab, I just used "before" with "Query" ticked. No other change on this business rule.
I am on Istanbul Patch 5.
Any idea why it's not working?
Cheers
Johnny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2017 03:51 AM
My experience with manipulations on sys_app_module before query business rule is really very unfortunate.
ServiceNow caches the menu on the combination of the roles the user has. No way to get different menu for users with matching role set, full stop. If you try to, you end up with unpredictable menus based on the fact, user entitled to what menu content accessed the menu first after the cache got invalidated. A nightmare, never bother with it.