
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2020 10:19 AM
I have an integration that receives a string value for the last online date of an endpoint.
In my Transform Script I would like to convert this string from Epoch time to a usable value. I have read a few posts and tried a script include and an onBefore script but I am unsuccessful with both.
The value coming in to my staging table is u_last_online and the field I wanna map to is u_addigy_last_online (date/time field)
Currently I am using the script onBefore in my transform map.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// convert and set account expiration date from AD
var dateConv = new DateConversion();
target.u_addigy_last_online = dateConv.int8ToGlideDateTime(source.u_last_online);
})(source, map, log, target);
This is the Script Include "DateConversion"
var DateConversion = Class.create();
DateConversion.prototype = {
initialize : function() {
},
int8ToGlideDateTime : function(int8Date) {
var msDate = new Packages.org.apache.poi.hpsf.Util.filetimeToDate(int8Date);
var gDate = new GlideDateTime();
gDate.setValue(msDate);
return gDate;
}
};
Thanks for any suggestions!
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2020 07:47 AM
I ended up using the following onBefore script in my transform map.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var lastOnlineTime;
var lastOnlineEpoch = source.u_last_online; //Whatever your epoch time is here
var gdtLastOnline = new GlideDateTime();
gdtLastOnline.setNumericValue(lastOnlineEpoch * 1000);
lastOnlineTime = gdtLastOnline.getValue();
target.u_addigy_last_online = lastOnlineTime;
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2020 10:58 AM
convert epoch time to GlideDateTime:
var epochTime = '1578912558000';
var gdt = new GlideDateTime();
gdt.setNumericValue(parseInt(epochTime));
gs.info('dt is ' + gdt.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2020 11:56 AM
How do I use that in my transform map?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 03:07 AM
change your script include:
var epochTime = your input value
var gdt = new GlideDateTime();
return gdt.setNumericValue(parseInt(epochTime));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 05:54 AM
it points to
1970-01-20 05:11:16