Set Automatically Incident state to In-progress from on-hold when "OnHold until" Date field was hit

Suresh_32
Tera Expert

Hi All,

We have a requirement, Once the "On hold until date" field was hit, the Incident would automatically go back into 'in progress' state. 

 

Suresh_32_0-1719412253093.png

 

created a Scheduled Job for this requirement but it is not working. please help me on this 

  

Suresh_32_0-1719411210484.png

 

Custom field type Date and Time "NowDateTime" and field value is 'u_nowdatetime' it is storing the current date/time. so that added if condition in above code with 'NowDateTime' field.

 

could you please help me on this requirement.

1 REPLY 1

Community Alums
Not applicable

Hi @Suresh_32 ,

you can update your script as below.

this script will run daily at time 00:00:01 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('state=3^u_on_hold_until_dateISNOTEMPTY');
gr.query();
while (gr.next()) {
    var time = new GlideDateTime(gr.u_on_hold_until_date);
    var td = new GlideDateTime();

    if (td >= time) {
        gr.state = '2';
        gr.update();
    }

}


If my response is useful please mark helpful or accept as a solution.

Thanks