Set Current Date Time In Business Rule Action

thisisauniqueus
Giga Expert

Hi

How can i set the value of a field(work start) to current Date Time based on another filed's value in a business rule action?

find_real_file.png

Regards.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Hi John,



Please see the link below.



Set date via business rule action



Regards,


Harshvardhan



PS - Please mark Helpful, Like, or Correct Answer if applicable.


View solution in original post

10 REPLIES 10

Chuck Tomasi
Tera Patron

The unscripted method is to use "same as" for the operator.



find_real_file.png



If you want a scripted method, check the advanced button and use the script field with a line of code (in place of the comment) like this:



current.work_start = current.u_other_date_time_field;



If you want to set it to the CURRENT date:



current.work_start = gs.nowDateTime();



GlideSystem Date and Time Functions - ServiceNow Wiki


Not working in Jakarta version

Can you share your code, any error messages, and what context you are using it in? Example: 

 

javascript:gs.nowDateTime() in a BR for a scoped app. <<-- This is a known issue and you'll get an error since this method isn't supported in scoped apps. You should be using GlideDateTime() in scoped, and global apps.

Table:

Requested Item(sc_req_item)

Business Rule:

After - update

 

Condition:

state changes to resolve

 

Code:

//gs.addInfoMessage("Resolved field update=" +gs.nowDateTime());
current.u_resolved_on_date=gs.nowDateTime();
current.update();

As you said, even i tried with the GlideDateTime() as well, but no luck.