Custom 'Created date' field capturing incorrect values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 11:08 PM
Hi All,
I have a requirement to capture the 'Created' i.e sys_created_on values on a new field that captures only the created date and not the time stamp for reporting purpose, same with the updated and closed fields
So i have created a new Date field 'Created date' and configured a business rule to update this field value.
But this newly created date field is not capturing correct values, there is a difference of a day (lag) between created dates in custom field and OOB field.
Can anyone suggest. Below are the details.
Business Rule
Type - Before Insert
Script-
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 11:19 PM
it's date type so your script is wrong as it's trying to set Date/time to Date field
use this if u_created is of Date type
var nowTime = new GlideDateTime();
var nowDate = nowTime.getDate();
current.setValue('u_created', nowDate);
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
‎04-07-2025 11:53 PM
Hi @Ankur Bawiskar ,
Thanks for your response. How can i use this code for Updated and closed fields as well. u_updated and u_closed_date being the custom fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 12:02 AM
for u_updated you will have to use before update business rule and have similar logic
for u_closed_date you can have before update business rule and condition as Ticket closes
Have similar 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 02:04 AM
Thanks @Ankur Bawiskar ,
Will make the changes and test. Hope it works overcoming timezone issues.