'Assignment group' and 'Assigned to' reset back to the initial value with the case closure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 02:11 AM
When the status is closed on the case, the "Assignment Group" and "Assigned to" fields value should reset to the initial value. These fields can have many different values in them while the case is ongoing and dozens of options you can choose to value for them. The BR script I'm trying to solve it, but it still doesn't seem to solve the it.
// Check if the state is changing to "Closed"
if (current.state == '6' && previous.state != '6') {
// Retrieve the initial values
var initialAssignmentGroup = current.assignment_group.getInitialValue();
var initialAssignedTo = current.assigned_to.getInitialValue();
// Reset the assignment group and assigned to to their initial values
current.assignment_group = initialAssignmentGroup;
current.assigned_to = initialAssignedTo;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 02:15 AM - edited 10-12-2023 02:18 AM
Hi @ElvinSalim ,
Can you elaborate more which previous values your are referring to ? Are these values change for each state change ?, And I saw you are not updating record within script.
Regards,
Mayur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 02:20 AM
I would like to reset the initial value that the case had when the case was first created. And while the case is open/ongoing these fields will likely change, but not dependent on any state change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 03:33 AM
Hi @ElvinSalim
Please try below code on after update BR and state changes to closed. Make sure assignment group & assigned to is populated when record is created else it will set both the fields to empty as initial value.
var grincident = new GlideRecord('incident');
if (grincident.get(current.sys_id)) {
var grhistory = new GlideRecord('sys_history_set');
grhistory.addQuery('id', current.sys_id);
grhistory.query();
if (grhistory.next()) {
var assignmentGrp = gs.getXMLText(grhistory.initial_values, "//assignment_group");
var assignedTo = gs.getXMLText(grhistory.initial_values, "//assigned_to");
}
grincident.setValue('assignment_group',assignmentGrp);
grincident.setValue('assigned_to',assignedTo);
grincident.update();
}
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 06:28 AM
The issue is deeper than I think, it's something to do with Inbound Email Actions and dealer action. So right now we're looking into it more. It probably we will not use any BR script instead of adjustment in Inbound Email Actions. I will update and give some feedback if we go the BR script way. Thanks.