Need Business Rule to run only in Native UI not on Service Portal

Bird1
Mega Sage

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?

1 ACCEPTED SOLUTION

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

 

 

 

View solution in original post

2 REPLIES 2

Paul Curwen
Giga Sage

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 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

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