- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 03:47 AM
Hi All,
I have a requirement as below.
Priority 1 incident should be created/updated by the current logged-in user belonging to A,B, C groups or user having Admin role.
I have created a business rule as follows.
When to run : Before --> Insert/Update and priority is 1
Advanced :
(function executeRule(current, previous /*null when async*/) {
if ((!gs.getUser().isMemberOf("A") || !gs.getUser().isMemberOf("B") || !gs.getUser().isMemberOf("c") || !gs.getUser().hasRole('admin))
{
gs.addErrorMessage('you dont have the right to create/update P1 tickets');
current.setAbortAction(true);
}
})(current, previous);
But it is checking the only first condition and not working for all the three groups.
Can someone help me with this please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 03:51 AM
Hi,
try this
(function executeRule(current, previous /*null when async*/) {
if (gs.getUser().isMemberOf("A") || gs.getUser().isMemberOf("B") || gs.getUser().isMemberOf("c") || gs.hasRole('admin')){
}
else{
gs.addErrorMessage('you dont have the right to create/update P1 tickets');
current.setAbortAction(true);
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 04:14 AM
I have an requirement that only specific group (P1 group) should create P1 ticket and Updation should be allowed by any one except urgency and priority fields. I had created 3 client scripts and it worked fine as now only P1 group members only able to create the P1 ticket and updation is allowed by any one. But now the requirement is updation of P4 or P3 or P2 should be changed to P1 by only P1 group members.But now any body are able to change to P1. Can you please help on this
I had attached screen shots of 3 client scripts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 03:52 AM
Hi,
Update it like below:
(function executeRule(current, previous /*null when async*/) {
if (!(gs.getUser().isMemberOf("A") || gs.getUser().isMemberOf("B") || gs.getUser().isMemberOf("c") || gs.getUser().hasRole('admin)))
{
gs.addErrorMessage('you dont have the right to create/update P1 tickets');
current.setAbortAction(true);
}
})(current, previous);
Thanks,
Anil Lande
Thanks
Anil Lande