Trouble setting Date/Time field with GlideDateTime in Transform Map Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi all,
I’m working on a data import in ServiceNow and I’m having issues updating a Date/Time field (u_due_date) using a field script in a Transform Map. My goal is to convert a date string from the import set to a valid Date/Time value in the target table.
Here’s my current script in the field map:
2025-11-18 14:30:00 (as a string in the import set)
The u_due_date field is not being updated after the transform runs—no errors, but the value isn’t set in the target record.
What I’ve checked:
- The field is of type Date/Time.
- The source data string matches the expected format (YYYY-MM-DD HH:mm:ss).
- No errors in the logs.
Question:
What am I missing or doing wrong when converting and returning a GlideDateTime in a Transform Map field script? Is there a better or safer way to do this conversion so the field is reliably updated?
Thanks in advance for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if the incoming value is having this format YYYY-MM-DD HH:mm:ss then no scripting required.
simply set this as Date format and it will get populated
Clear the source script and uncheck the "Use source script" field
Note: ensure there is no business rule etc which is clearing this field value
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
@Ankur Bawiskar Thanks for your quick response,
I have tried by removing source script and unchecked Use source script, still it is not working also there is no business rule for this field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
it should work fine ideally.
are you sure data is present in staging table
another approach
remove field map and try to use onBefore transform script like this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
target.setValue('u_due_date', source.u_due_date);
})(source, map, log, target);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
