The CreatorCon Call for Content is officially open! Get started here.

Set a date and time field from a business rule.

ServiceNowSteve
Giga Guru

Good Morning All,

I am running a business rule on my incident table which requires me to update a time field on a different table. I have tried several iterations of the code but nothing seems to work.

The line of code I am using is

data.setValue('u_timefield', gs.now());

I have also tried SetDisplayValue as well as trying

data.u_timefield =  gs.nowDateTime();

but still nothing. Any idea how I can accomplish this?

 

 

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

How about just

 

current.fieldName=new GlideDateTime();

-Anurag

View solution in original post

8 REPLIES 8

Thats fine

 

gr.fieldName=new GlideDateTime();

 

considering gr is the glide object to that record.

-Anurag

It runs but nothing happens...here's my full code...

 

var rr = new GlideRecord("u_round_robin"); //Queue up the Round Robin Table
rr.addQuery('u_active', true); //Find users that are active.
rr.orderBy('u_last_assigned'); // Order it by ths last assigned field
rr.orderByAsc('u_last_assigned'); //Sort it by oldest first.
rr.query(); //Start the search

if (rr.next()) //If the criteria is met run this.
{ 
gs.print(rr.getDisplayValue('u_technician.name')); //Works
gs.print(rr.getDisplayValue('u_last_assigned')); // Works
rr.u_last_assigned = new GlideDateTime(); // Will not update the users record.

}

var date = new GlideDateTime();
rr.u_last_assigned.setDisplayValue(date);

Please explain your requirement.

 

what data in your query.

In every table there are default created and updated date columns.

 

 

Thanks