I need to get the list of incidents(old incidents ) that were closed due to Auto closure functionality?

Reddy4811
Tera Expert

Dear all,

Scenario-1:-If the incident is in the state "solution proposed" and there is no action from the caller then it will be closed automatically after 5-days. (using BR)

Scenario-2:-if the incident is in the state "On Hold" and On Hold, the reason is "Awaiting User info". so in this case, if the caller is not responded to the incident up to 10days this incident will automatically be closed. (using Workflow)

My requirement is, I need to get all the list of those incidents which were closed based on the above scenarios, then I make the custom check box "true" on these incidents.

Could anyone please suggest to me the logic or some approach to do this....!

Please help

1 ACCEPTED SOLUTION

Hi,

data for comments and work_notes is stored in sys_journal_field

You can check for your incident record if there is any record in sys_journal_field with that comments or work notes value

if yes then it means it was closed by that scenario and then update the checkbox

Something like this

Ensure you give correct work_notes and comments text to find those records

var gr = new GlideRecord("incident");
gr.get("incidentSysId");

var rec = new GlideRecord('sys_journal_field');
rec.addEncodedQuery("name=incident^element=work_notes^valueLIKEclosed by scenario 1^ORvalueLIKEclosed by scenario 2");
rec.addQuery("element_id", gr.getUniqueValue());
rec.query();
if(rec.next()){
	
	// update your checkbox
	gr.u_checkbox = true;
	gr.update();
	
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Luis Bandeira
Tera Contributor

Hello,

You can try to query by the 'Closed By' field.

If it was automatically closed, it should be a service account, like the system admin.

BR

Appli
Mega Sage
Mega Sage

Hi feasible it would be to update BR/Workflow (being used to auto-close these incidents) adding an extra step that sets custom check box to True?

Hope it helps

Hope it helps

Hi @Appli,

I need to update the checkbox "Test"(field) to be "true". only for the incidents which are old incidents and already closed(Due to auto-closing), we need to update those records by using a background script.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you updating comments or work_notes when you update from both the scenario

that can help you determine.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader