Business Rule: update additional comments with assignment group when it changes

JP-ODU
Tera Guru

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?

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

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);

 

View solution in original post

6 REPLIES 6

Works perfectly. Thanks!

You are welcome!