transform map script to convert string form date format

Deepa12
Tera Contributor

Hi,

 

Below is the transform script i have tried into OnBefore, but i am getting the error "org.mozilla.javascript.EvaluatorException: Cannot convert NaN to java.lang.Long" .

 

   var gdt = new GlideDateTime();
    var mstime = (source.u_lastlogontimestamp);
    gdt.setNumericValue((mstime - 116444736000000000) / 10000);
    target.u_active_directory_last_login_date = gdt.getValue();
 
Deepa12_0-1738342848691.png

 

Pls advise the script to convert the string format to date format. Thanks.

1 ACCEPTED SOLUTION

@Deepa12 Thanks for marking the response helpful. Please mark it an accepted solution as well.

View solution in original post

8 REPLIES 8

Sandeep Rajput
Tera Patron
Tera Patron

@Deepa12 Please update the script as follows and see if it works for you.

 

if(source.u_lastlogontimestamp){
var gdt = new GlideDateTime();
var mstime = parseInt(source.u_lastlogontimestamp);
gdt.setNumericValue((mstime - 116444736000000000) / 10000);
target.u_active_directory_last_login_date = gdt.getValue();
}

Hope this helps.

Thanks for reply, Still i am getting the error message.

 

Deepa12_0-1738349158115.png

 

@Deepa12 What does the number 

116444736000000000

 

represent here in the calculation here.

 

The issue here is number doesn't represent a valid value in terms of date in Epoch date and time which is usually 13 digit long

The above onbefore script has worked after removed field map of lastlogontimestamp.