- 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
‎02-08-2022 03:50 AM
|| should be && for your logic, shouldn't it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2022 03:51 AM
Hi Teja,
Try below steps:
1) Have onSubmit client script
2) Get value of priority
3) Determine if logged in user is part of 'service Desk/your group name' group. this will be a flag either true/false
4) if (priority == 'high' && flag == true){
alert("you dont have access to create this ticket");
return false; // this will stop user from submitting the form
}
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- 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
‎02-08-2022 04:03 AM
Thank you