- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 12:41 AM
Dear Now Community Experts,
Context: Using a Transform Map, I am importing Active Directory (AD) data into a ServiceNow CMDB table.
Requirement: Convert the field value of' 'WhenCreated' (from AD) to a Date/Time format (in ServiceNow).
Sample value of 'WhenCreated' = 20181107064109.0Z
I tried the following sample script and it seems working.
---------------------------------------------------------
var d = '20181107064109.0Z';
var gdt = new GlideDateTime();
gdt.setValueUTC(d, 'yyyyMMddHHmmss');
gs.print(gdt.getDisplayValue());
---------------------------------------------------------
Script output:
*** Script: 07-11-2018 14:41:09
------------------------------------
Note: UTC time is converted to my local time (UTC+8)
Now, I would like to use this script to run on a "Field Map" in the Transform Map
so that the target field is updated in 'Date/Time' format. I tried the following script with no success.
---------------------------------------------------------
Could you please help me in correcting the script ?
Kind regards
Suresh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 02:10 AM
I tried same scenario using data source and import set and its working
data source:-
Transform map field script
It works as you see below it created in the table.
data type is date/time for timing field i created just now.
check you code , if issue persists, try using logs to see what is wrong
If this is helpful, mark answer as correct
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 02:37 AM
Check with logs if no luck, then
try in your PDI instance with your same import set.
I don't know what is missing for you.
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 03:28 AM
Sure, thanks I will give it go in my PDI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 12:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 12:50 AM
Yes sure try to recreate
There could be something missing maybe.
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 01:05 AM
I deleted the column (WhenCreated) and created again in the source and target tables, ran the Transform, it does not work ... weird and mysterious.
Here is the import log:
in the log, it seems like it is converting the string to date and time, but somehow it does not get updated in the target field. I cannot figure out what am I missing.