- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 10:07 AM
I am importing data for a date/time field through import sets into servicenow. Target filed is a date/time field on the sys_user table.
1. target field format is a date/time field, date format on user table is default - (system dd-mm-yyyy), time zone is default - System Europe/London
2. time format set for the field on transform map is dd-MM-yyyy HH:mm:ss
3. in import set (csv file), date field data is in format - dd/mm/yyyy HH:mm:ss
4.onBefore script -
var sourceDate = source.u_endtime;
var gdt1 = new GlideDateTime();
gdt1.setDisplayValue(sourceDate,'dd-MM-yyyy HH:mm:ss');
target.u_ooo_end_date = gdt1.getDisplayValue();
Issue is -
1. receiving error while importing data as - 'Unable to format 21/05/2020 05:00:00 using format string dd-MM-yyyy HH:mm:ss for field u_ooo_end_date'
2. When date in import file is in format - MM/DD/YYYY HH:mm:ss AM/PM , it is mapping it correctly
but when date in import file is in format - DD/MM/YYYY HH:mm:ss, (without AM/PM) it is not mapping correctly (eg. source date -
Is the issue because of slashes(/) in the csv file date field? Or is it because of different time zones?Maybe the one's coming as DD/MM/YYYY HH:mm:ss, (without AM/PM) from import can be from different time zone?
I have referred below kb article from HI support
https://hi.service-now.com/kb_view.do?sysparm_article=KB0622865
Anyone faced this issue before , please let me know the solution.
Thanks.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 01:08 AM
Hi,
please type this format in the field map date format and test once
dd/mm/yyyy HH:mm:ss
screenshot below
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 02:08 AM
h
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 05:11 AM
I am using below source script. Will this convert source field date which is actually coming as a 'string' to date/time value?
answer = (function transformEntry(source) {
var gdt = new GlideDateTime();
gdt.setDisplayValue(source,'dd-MM-yyyy HH:mm:ss');
return "gdt.getDisplayValue()";
})(source);
Because its still not giving correct output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2020 06:36 AM
Hi,
The best way to find out what value is being sent is try to log the values for few test records.
Thanks
Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 09:44 AM
Go to onafter TRANSFORM SCRIPT and use this over there. it will automatically capture the excel value to the field.
This script worked for me. Mark Helpful if this works for you.
run gliderecord on the target table. gr is the object of the gliderecord.
var dateTime = source.field_name;
var gdt = new GlideDateTime(dateTime);
gdt.setDisplayValue(dateTime);
var a = gdt.getValue();
gr.setValue('target_field_name', a);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 03:07 AM
this Article helped: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0622865