How to fill a field with all assignment groups that were on the incident

Alon Grod
Tera Expert

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.

 

Screenshot 2023-09-06 at 19.37.03.png

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

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".

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
Same BR is working for me in PDI.

 

 


Thanks and Regards,

Saurabh Gupta

Pradeep19
Tera Contributor

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