How to fill a field with all assignment groups that were on the incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 09:37 AM
Hi,
I have the field u_group_assignment_history of type List to sys_user_group. Im trying populate this field with all assignment groups that were on the incident. The problem that I have is that when the user create the incident, this field is not populated with the current assignment group. Only when the user changes the assignment group the functionality is working and the field populates with the previous and current assignment group but I need that this field will be populated with the current assignment group as soon as the user create the incident.
(function executeRule(current, previous /*null when async*/) {
if(current.u_group_assignment_history.toString().includes(previous.assignment_group.toString()))
current.u_group_assignment_history=current.u_group_assignment_history.toString()+','+current.assignment_group.toString();
else
current.u_group_assignment_history=current.u_group_assignment_history.toString()+','+previous.assignment_group.toString()+','+current.assignment_group.toString();
// Add your code here
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 01:01 PM
Hi Alon,
I tried the following script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
// Add previous group if present
if (previous.assignment_group != '') {
current.u_previous_assignment_groups += "," + previous.assignment_group.toString();
gs.info("TrackAssignmentGroups: adding " + previous.assignment_group.toString());
}
gs.info("TrackAssignmentGroups: u_previous_assignment_group = " + current.u_previous_assignment_groups);
})(current, previous);
I named my custom field 'u_previous_assignment_groups', defined as a List, length 4000, and Reference to sys_user_group. And added Condition: "Assignment Group", "Changes".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 10:11 AM
Hi,
Same BR is working for me in PDI.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 10:50 AM
List type field store sys_id of record, you have to search for sys_id insted of group name.
Please mark the answer as correct and helpful, If I answered your query. It will be helpful for others who are looking for similar questions. Best Regards, Pradeep