We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Set the checkox 'u_resolution' to 'true' if the incident assignment group is same from beginning

Trupti Krishnam
Tera Contributor

1.I have a requirement to set the Checkbox 'u_resolution' to set to true. If the assignment group field of the incident record remains unchanged from the beginning to end of an incident.

2. If the incident is assigned to Assignment group ' IT support' in the beginning and then the assignment group is set to  'Help Desk' and then at later point of time it is assigned to 'IT Support' again even at this point it has to set to checkbox 'u_resolution' to true

can anyone help with this!

thanks!

9 REPLIES 9

Tanushree Maiti
Giga Sage

Create a business Rule when a incident state chage to Resolve,

In advance script ,

1. Check incident_metric table for that incident , if 1 record exist (against definition = Assignment group), then set u_resolution =true //assignment group field of the incident record remains unchanged from the beginning to end of an incident.

 

2. If more than than one entry is there , put logic in code , that if 1st and last is same then u_resolution =true.

e.g first assigned INC to Network E assignment group

                                               Netscout S group

                                               Network E assignment group  //"End" field empty means it was assigned during resolve

TanushreeMaiti_0-1770715709106.png

 

                                              

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

ShrikantP549033
Giga Contributor

Hii @Trupti Krishnam 

Here’s the recommended approach to set the u_resolution checkbox when the Assignment Group of an incident remains the same as the initial value:

 

1. Store the initial Assignment Group

  • Create a new field (if not already present) to store the initial Assignment Group.

    • Example: u_initial_assignment_group (type: reference → Assignment Group).

  • Capture the initial Assignment Group when the incident is first created using a Before Insert Business Rule

// Before Insert Business Rule
if (!current.u_initial_assignment_group) { current.u_initial_assignment_group = current.assignment_group; }

 

 

2. Update the checkbox based on Assignment Group changes

  • Use another Before Update Business Rule to check changes:

    • Condition: assignment_group.changes() (optional, only if assignment group is updated)

  • Script:

 

// Before Update Business Rule
// Check if current assignment group is the same as the initial if (current.assignment_group == current.u_initial_assignment_group) { current.u_resolution = true; } else { current.u_resolution = false; // optional if you want to reset when different }

This ensures that u_resolution is set to true if the current Assignment Group matches the initial Assignment Group, even if it changed temporarily in between.

 

If my Answer helped, please mark it as correct.



ShrikantP549033
Giga Contributor



If my Answer helped, please mark it as correct.



yashkamde
Kilo Sage

Hello @Trupti Krishnam ,

 

I had done your requirement, 

Make one after update Business rule and use this logic :

(function executeRule(current, previous) {

    // run only when resolving or closing (change state values if needed)
    var grAudit = new GlideRecord('sys_audit');
   grAudit.addQuery('documentkey', current.sys_id);
   grAudit.addQuery('tablename', 'incident');
   grAudit.addQuery('fieldname', 'assignment_group');
   grAudit.orderByDesc('sys_created_on');
   grAudit.setLimit(1);
   grAudit.query();

if (grAudit.next()) {
    if (current.assignment_group.toString() == grAudit.newvalue) {
        current.u_resolution = true;
        current.update();
        gs.info('done123 - assignment group unchanged');
    }
} else {
    gs.info('not done - no audit record found');
}
})(current, previous);

 

If my response helped mark as helpful and accept the solution..

Hello @Trupti Krishnam ,

 

Does my response helped you ?

for more optimized and feasible solution you can also refer this code :

if (current.state == '6' || current.state == '7') {
        var gr = new GlideRecord('sys_history_set');
        gr.addQuery('table', 'incident');
        gr.query();

        while (gr.next()) {
            var idDisplay = gr.id.getDisplayValue();
			gs.log('1  ' + idDisplay);

            if (idDisplay.toString().includes(current.number.toString())) {
				gs.log(2);
                var gr1 = new GlideRecord('sys_history_line');
                gr1.addQuery('set', gr.getUniqueValue());
                gr1.addQuery('label', 'Assignment group');
                gr1.addQuery('update', 0);
                gr1.query();

				gs.log(3);
                if (gr1.next()) {
					gs.log(4);
                    if (gr1.getValue('new') == current.assignment_group.getDisplayValue()) {
                        current.u_resolution = true;
                        current.update();
                        gs.log('Unchanged YASH');
                    }
                }
            }
        }
    }

 

If my response helped mark as helpful and accept the solution..