Compare field date/time with system date and time in scheduled job

Mishu
Tera Expert

To change state value to Open when custom date/time field (Reactivation Time) value matches with system date/time.

I am trying with below code, which is not giving the output.

Is there anything i am missing here ? Kindly Suggest 

 

var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('state=30^u_reactivation_timeISNOTEMPTY');
gr.query();
while (gr.next()) {

var reopen_date = new GlideDateTime(gr.u_reactivation_time);
var today_date = GlideDateTime();

if (reopen_date == today_date) {
gr.state = '10';
gr.work_notes = 'Updated State to Reopen';
gr.update();
}

1 ACCEPTED SOLUTION

@Mishu 

if you are ok with Date then use scheduled job script.

If you are ok with minutes without thinking about seconds value then use flow designer.

But running flow every minute will lead to performance issue.

Please discuss with your customer about this.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@Mishu 

workflow why?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader