Value from Active Directory for the field 'Password Last Set' is not in the date and time format.

AbdulRahman89
Giga Contributor

I have configured ServiceNow to query and fetch User and Generic Accounts. However two fields which are flowing from MS Active Directory namely 'Password Last Set' and  'Last Logon' seems to be in completely different format other than date and time.

I have tried the following script but it does not seem to work.

 

====================================

answer = (function transformEntry(source) {
var gdt = new GlideDateTime();

var s = source.u_pwdlastset;

gdt.setNumericValue((mstime - 116444736000000000)/10000);

var lastset = gdt.getValue();
return lastset;

})(source);

==================================

Also I have tried the solution provided in the below article, which does not seems work at all.

https://community.servicenow.com/community?id=community_question&sys_id=c5ba0f2ddb5cdbc01dcaf3231f9619f3&view_source=searchResult

 

 

I would appreciate if you could review this in detail and help me with your expertise. 

1 ACCEPTED SOLUTION

AbdulRahman89
Giga Contributor

Here is the solution:

 

 

answer = (function transformEntry(source) {

var gdt = new GlideDateTime();
var mstime = parseInt(source.u_pwdlastset);
gdt.setNumericValue((mstime - 116444736000000000)/10000);
log.info(gdt.getValue()+'date');
return gdt.getValue(); // return the value to be put into the target field

})(source);

View solution in original post

5 REPLIES 5

AbdulRahman89
Giga Contributor

Here is the solution:

 

 

answer = (function transformEntry(source) {

var gdt = new GlideDateTime();
var mstime = parseInt(source.u_pwdlastset);
gdt.setNumericValue((mstime - 116444736000000000)/10000);
log.info(gdt.getValue()+'date');
return gdt.getValue(); // return the value to be put into the target field

})(source);