UI Policy script to make a field autopopulate current date and time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 02:02 PM
Hi,
I want to make a field auto populate current date and time using UI policy. Depending on other field. Please advice.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 02:08 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 02:12 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 02:21 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2017 08:47 AM
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