UI Policy script to make a field autopopulate current date and time

manoj12398
Giga Contributor

Hi,

I want to make a field auto populate current date and time using UI policy.   Depending on other field. Please advice.

8 REPLIES 8

Inactive_Us1474
Giga Guru

Hi Manoj,



You need to add a default value of the field as javascript:gs.nowDateTime(); to get current date and time in date time field.


Using UI Policy you can only make fields as readonly/visible/mandatory based on conditions.


Creating a UI Policy - ServiceNow Wiki



Thanks


Akhil


Hit Like/Helpful/Correct, if applicable.


Thanks Akhil,


Actually Can we implement it by client script because as soon as I change a value in one field, other field should populate the current date and time. Please help me with script


It can be done using client script. Create an onChange() client script and use the code in this article: Set Current DateTime In Field - ServiceNow Wiki


johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Date and Time Fields
   



 


Visit http://docs.servicenow.com for the latest product documentation