- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 01:20 PM
Hello, All! I just upgraded to San Diego and a few of my business rules started going wonky. I'm trying to fix this one for my INCs, but I can't seem to do it. I have a role (ASDM) that I put in just for one group so I can call it here due to a business need. The BR trigger is below in a screenshot, and then this code is supposed to run. The part I really care about is this...
1. If the person making the update to the ticket IS the Assigned To person, then the state should stay as it is because the BR isn't running.
2. If the person making the update to the ticket ISN'T the Assigned To person, then check to see if the person has the role ASDM. If he DOES have that role, keep the state as it was originally. However, if he DOES NOT have that role, then change to In Progress (state value 2).
Can anyone help me to figure out how to tweak the below code to get it to do what I want it to do up above please?
Thank you!!
(function executeRule(current, previous /*null when async*/ ) {
var user = current.sys_updated_by;
var gr = new GlideRecord("sys_user_has_role");
gr.query();
while (gr.next()) {
if (user.role == "ASDM") {
current.short_description = "I AM DEB!";
}
if (user.role != "ASDM") {
current.short_description = "I AM not DEB!";
current.state = 2;
}
gr.update();
}
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Service Desk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 01:42 PM
Hi,
For the condition part, I assume you have that under control or can figure that part out.
For the script though, here's some assistance:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('role.name', "ASDM"); //only look for role.name ASDM
gr.addQuery('user', gs.getUserID()); //only look for this user
gr.query();
if (gr.next()) {
current.short_description = "I AM DEB!";
} else {
current.short_description = "I AM not DEB!";
current.state = 2;
}
})(current, previous);
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 01:42 PM
Hi,
For the condition part, I assume you have that under control or can figure that part out.
For the script though, here's some assistance:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('role.name', "ASDM"); //only look for role.name ASDM
gr.addQuery('user', gs.getUserID()); //only look for this user
gr.query();
if (gr.next()) {
current.short_description = "I AM DEB!";
} else {
current.short_description = "I AM not DEB!";
current.state = 2;
}
})(current, previous);
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2022 05:49 AM
That was just what I needed - thank you, Allen!