- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 02:56 AM - edited 01-22-2025 03:03 AM
Hi All,
Requirement:
Populate a date field in a table with the current date when the XYZ field has a specific value. Additionally, users should be able to modify the date field if needed.
To achieve this, I have created a UI Policy with the condition that the XYZ field matches the specified value.
In the UI Policy Script field, I added the following script:
Question:
Is this the correct approach?
Currently, the field is being populated, but not in the desired format. it is populated as below screenshot:
Expected Outcome:
The field should be populated with the current date in the format dd/mm/yyyy hr:mm:ss (e.g., 22/01/2025 16:47:56).
Can someone help me achieve this?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 04:04 PM
Hi All,
I used the client script with the following codes and it worked the way I wanted. Though of sharing it as it might be helpful for others.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 03:55 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 06:57 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 04:03 AM
I tried the following code in my UI Policy script. While this sets the date field value, the date value is inconsistent such as - 28/01/2025 22:57:3 OR 28/1/2025 15:1:35 and hovering the mouse to the date field sometime says 2 hours ago or 55 year ago. Would appreciate if anyone can share what is wrong with the following code.
Regards,
Sandhya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 04:48 AM
the inconsistency is because of the logged in user's date format.
Try the script I shared and it will handle the different date formats for different logged in user
I believe I have provided enough guidance and a working script.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader