- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 01:51 PM
I've been trying to get this script working, but I'm clearly getting something (or multiple somethings) wrong.
Goal: if the assignment group on an Incident is updated, then update additional comments saying "This ticket has been assigned to [assignment group selected]"
Table: Incident
Active: True
Advanced: True
before Update
Filter conditions: Assignment group | changes AND Assignment group | is not empty
Script:
(function executeRule(current, previous) {
// Get the assignment group information
var assignedGroup = new GlideRecord('assignment_group');
if (assignedGroup.get(current.assignment_group)) {
var assignmentGroup = assignedGroup;
// Add a comment with the assignment group
var comment = 'The ticket has been updated. Assigned to: ' + assignmentGroup;
current.comments = comment;
}
})(current, previous);
Can anyone see how to fix this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 02:01 PM
In a GlideRecord, the value in quotes following is a table name. assignment_group is not the name of a table, so this should be replaced with sys_user_group, but since Business Rules run on the server, you can dot-walk to the name of the group, so don't even need a GlideRecord. Your script can simply be:
(function executeRule(current, previous) {
// Add a comment with the assignment group
var comment = 'The ticket has been updated. Assigned to: ' + current.assignment_group.name;
current.comments = comment;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 02:01 PM
In a GlideRecord, the value in quotes following is a table name. assignment_group is not the name of a table, so this should be replaced with sys_user_group, but since Business Rules run on the server, you can dot-walk to the name of the group, so don't even need a GlideRecord. Your script can simply be:
(function executeRule(current, previous) {
// Add a comment with the assignment group
var comment = 'The ticket has been updated. Assigned to: ' + current.assignment_group.name;
current.comments = comment;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 02:03 PM
I don't think that script is doing what you need it to...you don't need any glide here.
var curAssgnGroup = current.assignment_group;
var prevAssgnGroup = previous.assignment_group;
if (curAssgnGroup != prevAssgnGroup) {
current.comments = "The ticket has been updated. Assigned to: ' + curAssgnGroup;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 05:36 AM
I found where I was misplacing parentheses and now have it *almost* working... Using the below script gets me the sysID of the assignment group, not it's name? How do I fix that?
(function executeRule(current, previous) {
var curAssgnGroup = current.assignment_group;
var prevAssgnGroup = previous.assignment_group;
if (curAssgnGroup != prevAssgnGroup) {
current.comments = "The ticket has been updated. Assigned to" + curAssgnGroup;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 05:45 AM
Use the right answer, previously provided. You don't need the current vs previous comparison in the script since you have the Filter conditions on the When to run tab.