- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 03:04 AM - edited 12-06-2022 05:34 AM
I create business rule 'before' + 'query' to restrict view on 'sn_sm_legal_request' table.
The purpose is we need to restrict the Native UI record to only member to see the ticket as below example if the user is member of SM China Legal, he/she will be able to see the record that assign to SM China Legal (if the ticket assign to other group under this table, he/she won't be able to see it).
if (gs.getUser().isMemberOf('7d486c028786c1d0a62420e5cebb35bb')) { //the user is in SM Legal
current.addEncodedQuery('assignment_group=7d486c028786c1d0a62420e5cebb35bb'); //Legal tickets
I got the issue because today the user (member of SM Legal) submit ticket and it needs to be assigned to another group SM US Legal. She cannot see her own record on Service Portal because of this business rule.
Any idea how to make business rule runs only on Native UI not on Service Portal?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2022 12:53 AM
Hi Paul,
Thanks a lot. Your script was working but not perfect, The encoded query was working fine only when the first time load but when I tried to switch between 'my open request' , 'my close request', the set abort does not work. The solution is required to refresh the URL, so the abort true will be workable again.
Finally I updated the script again to be as below and it's working perfect!
if (GlideTransaction.get().getRequest().getHeader("referer").indexOf('esc') > -1) { setAbortAction(true) }
else if (gs.getUser().isMemberOf('7d486c028786c1d0a62420e5cebb35bb')) { //the user is in SM Legal
current.addEncodedQuery('assignment_group=7d486c028786c1d0a62420e5cebb35bb'); //Legal tickets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 07:00 AM - edited 12-09-2022 07:00 AM
In your Business Rule script use the following code:
if (gs.action.getGlideURI().toString().indexOf('sp') > -1) {
setAbortAction(true)
}
Note in the above set sp to be the suffix of your Service Portal.
If this helps please mark as Helpful/Correct
Regards
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2022 12:53 AM
Hi Paul,
Thanks a lot. Your script was working but not perfect, The encoded query was working fine only when the first time load but when I tried to switch between 'my open request' , 'my close request', the set abort does not work. The solution is required to refresh the URL, so the abort true will be workable again.
Finally I updated the script again to be as below and it's working perfect!
if (GlideTransaction.get().getRequest().getHeader("referer").indexOf('esc') > -1) { setAbortAction(true) }
else if (gs.getUser().isMemberOf('7d486c028786c1d0a62420e5cebb35bb')) { //the user is in SM Legal
current.addEncodedQuery('assignment_group=7d486c028786c1d0a62420e5cebb35bb'); //Legal tickets