Incident State from "on hold" to "in Progress"

Steve2000
Tera Contributor

I want to change regularly all "on Hold" Incidents and where the "follow up" fields are exceeded that the field values of "follow up" are cleared and the "State" changes to "in Progress" 

Also I want to fill in a Work Note saying "The Incident changed to "in Progress" because the "Follow Up" is exceeded.

 

I´m a rookie with this platform and I´m overwhelmed by the possibilities of this platform 🙂

I´m very thankful in advance 🙂

2 ACCEPTED SOLUTIONS

RaghavSh
Kilo Patron

You can run a scheduled job daily (or as per your convenience)  for this with below code:

var inc = new GlideRecord('incident');
inc.addEncodedQuery('state=3^follow_up<javascript&colon;gs.beginningOfToday()'); // will fetch on hold incident with follow up date before today, so when it will run daily, all incidents will be covered.
inc.query();
while(inc.next())
{
inc.state=2;
inc.update();
}

 Note: All scripts should be tested in dev before execution in prod.


Raghav
MVP 2023

View solution in original post

Scheduled job, which will run daily. (sysauto) table.

Screenshot 2022-12-19 at 4.58.03 PM.png

For more info refer : https://docs.servicenow.com/en-US/bundle/tokyo-platform-administration/page/administer/reference-pag... 


Raghav
MVP 2023

View solution in original post

5 REPLIES 5

RaghavSh
Kilo Patron

You can run a scheduled job daily (or as per your convenience)  for this with below code:

var inc = new GlideRecord('incident');
inc.addEncodedQuery('state=3^follow_up<javascript&colon;gs.beginningOfToday()'); // will fetch on hold incident with follow up date before today, so when it will run daily, all incidents will be covered.
inc.query();
while(inc.next())
{
inc.state=2;
inc.update();
}

 Note: All scripts should be tested in dev before execution in prod.


Raghav
MVP 2023

For my understanding. Do I write this in a Client Script or a UI Policy?

Scheduled job, which will run daily. (sysauto) table.

Screenshot 2022-12-19 at 4.58.03 PM.png

For more info refer : https://docs.servicenow.com/en-US/bundle/tokyo-platform-administration/page/administer/reference-pag... 


Raghav
MVP 2023

@Steve2000 if your issue is fixed, do mark the relevant answer correct to close the thread.


Raghav
MVP 2023