if incident is closed the assignment group should be autopopulate tag field in task sla related list

srikriti
Tera Contributor

Hi Team.

I have scenario like where incident state is closed state the assignment group should be populate in task sla related list we have Tag field in that assignment group should be populate anyone have idea on this.

srikriti_0-1727956258399.png

 

 

Thanks

3 REPLIES 3

Rajesh Chopade1
Mega Sage

hi @srikriti 

you can create a business rule that triggers when the Incident's state changes to "Closed." This rule will check the Assignment Group and set the Tag field in the Task SLA.

 

Create 'after' Update BR on 'incident' table and add condition as 'State changes to Closed'.

Add bellow sample script in script section:

(function executeRule(current, previous /*null when async*/) {
    if (current.state.changesTo('Closed')) {

        var assignmentGroup = current.assignment_group;

        // Find the associated Task SLA records
        var taskSLA = new GlideRecord('task_sla');
        taskSLA.addQuery('task', current.sys_id); 
        taskSLA.query();

        while (taskSLA.next()) {
            // Populate the Tag field with the Assignment Group
            taskSLA.assignment_group = assignmentGroup; // Set the assignment group
            // Assuming Tag field is 'tag' in task_sla table
            taskSLA.tag = assignmentGroup.getDisplayValue(); // Set the tag value (if needed)
            taskSLA.update(); // Save the changes
        }
    }
})(current, previous);

Ensure that tag is the correct field name in your task_sla table. You may need to adjust the script if the field has a different name.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

Hi,

its not a field on the task sla form its an just add tag concept field where it will available on list view not on the form so i have added like this in the script but its not fetching the value in that tag field 

srikriti_0-1727960700746.pngsrikriti_1-1727960724950.png

 

HI @srikriti 

Tags are stored in the table label and the reference of tags are stored in the table label_entry.

 

To achieve your requirement you need to add the AG in table label first and then via BR initialize the new record in table label_entry. Also in table label_entry you need to add 'target' field in format of 'task_sla.do?sys_id=03d8c106d732220035ae23c7ce6103fd&sysparm_view=' .

This all the changes will make the all functionality more complex and as per my knowledge, storing assignment group in table label not recommended.

 

Here I will suggest you create custom field and store the assignment group there. 

NOTE - custom field creation having some cost associated with it.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh