Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

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

Raghav Sharma24
Giga 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.

View solution in original post

5 REPLIES 5

@Raghav Sharma24 

When i am running the schedule job for every 5 mints its not working for me and state of the incident is not changing to in progress .  Please find the attached screen shots along with logs . Please let me know if anything has to be modified in the script 

 Script :  

var s= new GlideRecord("incident");
    s.addEncodedQuery("state=3^sys_updated_on<javascript&colon;gs.beginningOfToday()");
    gs.info("hello 3");
    s.autoSysFields(false); // use if you don't want update system fields
    s.setWorkflow(false);
    gs.info("hello4");
    s.query();
    while(s.next())
        {
            s.setValue("state",2);
            s.update()
            gs.info("hello5");
        }

sushma9_0-1699148618094.png

sushma9_1-1699148656751.png

 

sushma9_2-1699148711874.png