Make Incident state to In-progress when on-hold and "waiting until" Date field will reached

Pratiksha KC
Tera Guru

Make Incident state to In-progress automatically when on-hold and "waiting until" Date field was reached for Europe/ Berlin Time zone. 

 

I have wrote the Scheduled Job script - Selected Timezone as - Europe/ Berlin

 

var gr = new GlideRecord('incident');
gr.addQuery('state''3'); // On Hold
gr.addNotNullQuery('u_waiting_until');
gr.query();

while (gr.next()) {
    var holdUntil = new GlideDateTime(gr.getValue('u_waiting_until'));
    var now = new GlideDateTime();

    if (now.compareTo(holdUntil) >= 0) {
        gr.state=2// In Progress
        gr.update();
    }
}
 
But it is not working. Should I have to convert UTC time zone to particular timezone ? 
Please guide me through this. 
 
Attached Screenshot for reference - 
PratikshaKC_0-1748546562514.png

 

3 REPLIES 3

James Chun
Kilo Patron

Hi @Pratiksha KC,

 

Your script is fine, but the priority is being overwritten by the priority lookup.

I would suggest you update the impact and urgency fields instead to escalate the priority.

 

Cheers

Hi @James Chun 

 

Thanks for your reply, but I'm not using or setting the priority field on incident form. I wants to update the state field to In - progress when date is reached. 

 

Thank You!

Sorry, I don't know what I was thinking 😅

 

But yes, your script looks fine to me, I don't believe there is a need to convert the time zone.

When you say it's not working, do you know where it's not working? Have you narrowed it down to identify if it's one of the following areas?

  • GlideRecord query (i.e. no records are returned with the query)
  • IF statement (i.e. now.compareTo(holdUntil) >= 0, or
  • Setting the state field

Try adding some log statements between the script for debugging.

 

Cheers