need to change incident automatically when offhold date completed

Vani14
Tera Contributor

We have created an offhold date for on hold reasons; whenever the offhold date is reached, the incident state should be changed to inprogress automatically.

 

Vani14_0-1691202826125.png

 

11 REPLIES 11

I think this won't work. There is no field change, so the flow will probably not pick this up.

I would suggest to create a scheduled event, which triggers a script action once the schedule has been reached.

 

See for your reference:

Script actions (servicenow.com)

GlideSystem | ServiceNow Developers


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

You can also try, wait for duration action, 1 second after your field 

heres a screenshot: 

 

Screenshot 2023-08-08 at 8.39.49 PM.png

Vani14
Tera Contributor

I created a scheduling job, and it works as planned, but anytime worknotes updates, it displays my name, whereas it should appear as system. How can we achieve this?

Run: Periodically

var gr = new GlideRecord("incident");


gr.addQuery('state', 3); // state is onhold


gr.query();

 

while(gr.next())


{


var diff = gs.dateDiff(gs.nowDateTime(), gr.u_off_hold_date.getDisplayValue(), true);

 

if(diff<0){


gr.state = 2; // state set to inprogress


gr.work_notes = "Off hold date is passed";


gr.update();


}


}

 

Vani14_0-1691759071525.png

 

Hi @Vani14,

There is a field Run as on the Scheduled Job table, might not be in the default view.
You could select System Administratr as the Run as user.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.