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

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepa12 

you are trying to set value to date/time but it's not a date/time value

It's a string

Is "116444736000000000" a duration value in milliseconds?

if yes then you need to have target field as duration and not date/time.

Date/time and duration both are different field types and have different purposes.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Deepa12 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Deepa12 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader