- 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-25-2022 01:12 AM
Your log says updates 425,
It means it updated the 425 entries because all the record already exists from previous imports.
Its not creating new ones as its updating each record by matching the fields.
Try to first clean/delete the records in that temporary source table then import and execute the transform map
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 09:09 PM