All resolved Incident tickets of last month will get auto closed on every 1st of current month.

Charan5
Tera Contributor

Hi 

please let me know the code

All resolved Incident tickets of last month will get auto closed on every 1st of current month.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can be easily done using flow designer

1) Flow triggers on 1st of every month

2) checks which incidents are resolved on last month

3) Iterate those and close by setting the state and any other mandatory fields

Remember to save and Activate the flow

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Raghu Ram Y
Kilo Sage

Hi,

Create a schedule job like below..

find_real_file.png

Sharing the code as well

var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_updated_onONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()^state=6');
gr.query();
while (gr.next()) {
    gr.state = '7'; //mention your closed state number;
    gr.update();
}

manu7867
Tera Contributor

Hi charan,

try this in schedule job

var gr = new GlideRecord('incident');

gr.addEncodedQuery('state=6^resolved_atONlastmonth@javascript:gs.beginningOfLastMonth()@javascript: gs.endOfLastMonth()');

gr.Query();

while(gr.next())

{

gr.state='7';

gr.work_notes='Close all the resolved incident through Scheduled Job Script';

gs.log('Demo schedule Job executed');

gr.update();

}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can be easily done using flow designer

1) Flow triggers on 1st of every month

2) checks which incidents are resolved on last month

3) Iterate those and close by setting the state and any other mandatory fields

Remember to save and Activate the flow

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

Regards
Ankur

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