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 update date field to current date and time

Zuri
Tera Expert

I want to run background scripts to update resolved date to current date and time

var gr = new GlideRecord('sn_customerservice_case');
gr.addQuery("sys_id","3751d2e11be113d9c4bcb7d"); 

gs.print(gr.getRowCount());
gr.query();
while(gr.next())
{

gr.state = 6 ;
//update resolved date
gr.resolved_at = (current date and time);
gr.update();

 

1 ACCEPTED SOLUTION

Nayan Mahato
Tera Guru

Hi Zuri,

Use gs.nowDateTime();

 

var gr = new GlideRecord('sn_customerservice_case');

gr.addQuery("sys_id","3751d2e11be113d9c4bcb7d");

gs.print(gr.getRowCount());

gr.query();

while(gr.next()){

gr.state = 6 ;

//update resolved date

gr.resolved_at = gs.nowDateTime();

gr.update();

 }

Regrads,

Nayan

 

 

 

View solution in original post

1 REPLY 1

Nayan Mahato
Tera Guru

Hi Zuri,

Use gs.nowDateTime();

 

var gr = new GlideRecord('sn_customerservice_case');

gr.addQuery("sys_id","3751d2e11be113d9c4bcb7d");

gs.print(gr.getRowCount());

gr.query();

while(gr.next()){

gr.state = 6 ;

//update resolved date

gr.resolved_at = gs.nowDateTime();

gr.update();

 }

Regrads,

Nayan