Schedule Job Execution to update a Date Field

Community Alums
Not applicable

Hello All,

 

I am looking for a server side script to run daily on a scheduled job execution to update a custom Date field (u_glide_date_1) to the current date.  I have a function field that displays the datediff between an Expiry Date field and Current Date field (u_glide_date_1), but I need an accurate current date every day for my function field to be correct. 

 

Thank you 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

I found this script to run in a Scheduled Job and does what I need it to do:

 

var gr = new GlideRecord('table_name');  //call the table

gr.addQuery('active', 'true');  //only update active records

gr.query();

while(gr.next())

{

gr.update();    //make update changes - OF WHICH THERE ARE NONE

gr.setForceUpdate(true);  //force the record to update even though no actual changes have been made

}

View solution in original post

2 REPLIES 2

Claude DAmico
Kilo Sage

Try this.

new GlideDateTime.getDate();
Claude E. D'Amico, III - CSA

Community Alums
Not applicable

I found this script to run in a Scheduled Job and does what I need it to do:

 

var gr = new GlideRecord('table_name');  //call the table

gr.addQuery('active', 'true');  //only update active records

gr.query();

while(gr.next())

{

gr.update();    //make update changes - OF WHICH THERE ARE NONE

gr.setForceUpdate(true);  //force the record to update even though no actual changes have been made

}