Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to manage Timezones in Scheduled jobs

rpoola
Tera Contributor

Hi, i am running scheduled job daily. I am fetching change request records when current date in more than Planned start date. But it is not working as per expected. Planned start date is 7 or 8 hours different from appearing in the form. I am not understanding when does daylight saving comes into picture. How can I bring current date, planned start date(which is 7 or 8 hours different from showing in form) into same format & compare.

This is the script i am running in scheduled job

var change=new GlideRecord('change_request');

change.addQuery('state', '-4'); //state is assess

change.addQuery('start_date','<',gs.nowDateTime());

change.addActiveQuery();

change.query();

while(change.next()){

    var sys_id= change.sys_id;

    var gr = new GlideRecord('sysapproval_approver');

    gr.addQuery('sysapproval', sys_id);

    gr.addQuery('state','requested');

    gr.addQuery('sysapproval.sys_class_name','change_request');

    gr.query();

    while (gr.next()) {

                gr.state="rejected";

                gr.update();

    }

}

1 REPLY 1

Deepak Kumar5
Kilo Sage

Change Run as Timezone from list layout or Run as to user with the same time zone you want to run.


find_real_file.png