Before Query business rule to hide an Application from user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2017 08:27 PM
Hi SNC
Before Query business rule has been created to hide an application for users with specific property in User table. When I impersonate and verify, it is not working for all users and Business rule also not executing for all users. can anybody tell me why before query business rule on Application Menu table is not executing for all users?
var usr = gs.getUser().getRecord().getValue('field');
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2017 09:43 PM
If i am not wrong because of ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2017 10:59 PM
Hide Application or Module
Table: Application Menu [sys_app_application] or Module[sys_app_module]
When: before
Query = true
if(!gs.getUser().isMemberOf('Group A') && !gs.getUser().isMemberOf('Group B') && !gs.getUser().isMemberOf('GroupC') && !gs.hasRole('admin'))
{
current.addQuery('sys_id','!=','5212632ced4f5500b14f689a971ad873');//sys_id of the application
}
Above scripts should hide an application (sys_id =5212632ced4f5500b14f689a971ad873) or can be used to hide module (change the table you run the BR and the sys_id to that of the module you want to hide) for all users who are not part of Group A or B or C or are not admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2018 09:22 AM
This does not work for me. Is there anything else I would have to do?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2019 12:32 PM
Hi,
I just wanted to reply to say that I recently was brought with a requirement to hide a module based off of role (which disallowed me the ability to allow...roles...because there was a conflict there...that's another story...). You can use this same method to hide modules based off of really anything...but you need to ensure you do these things:
1) Use the sys_app_module table for your Business Rule
2) Run Before
3) Query type
4) Use script/advanced section to set the visibility by using something like this:
if (gs.getUser().hasRole('itil')) {
current.addQuery('sys_id', '!=', 'sys_id_of_module');
}
To get the sys_id of the module, you can hover the module in left-hand navigation and click pencil icon, which will take you to the settings page...right-click gray header area and choose "Copy Sys ID".
5) This is the most important step that I was initially missing and I figured it out...YOU MUST CLEAR INSTANCE CACHE (type cache.do in to the left-hand navigation search bar) to flush the cache out.
The reason #5 is necessary is because the modules are stored in the cache...so if you're now trying to limit it and it was already there before the BR was created/active...then it will appear to not work. Clearing the cache sort of resets the module appearance and the BR then takes effect.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!