Account expiry dates

andrewnorris
Giga Contributor

Hello

We currently import our users from active directory to SNC via the LDAP plugin. I want to bring over the account expiry dates too but as this is stored in Integer8 format it will need some transform scripting to get it to show a human-readable date format.

I'm afraid I have no idea how to convert Integer* to the current date format. Can anyone offer help or guidance?

Thanks
Andy

33 REPLIES 33

Strange! Do you have a personal timezone setting on the instance? Or is your profile running off the system timezone?


yes, timezone - Canada Eastern.


Hello all,


I just tried to implement this in our dev environment and i see the string coming across after the transform in the import set log (still in the format of 130748436000000000)   but it isn't converting it and putting it into my u_account_expires on my sys_user table (blank fields).



I checked in my system logs and see warnings stating the following, any thoughts?




java.lang.SecurityException: Illegal attempt to access class 'com.glide.glideobject.GlideDateTime' via script


    Caused by error in <refname> at line 10




          7: // Only convert AD accountExpires values that begin with 1 (ex. 0 represents never expires)  


          8: if (s.charAt(0) == 1) {  


          9:       var msDate = new Packages.org.apache.poi.hpsf.Util.filetimeToDate(n);  


==>   10:       var gDate = new Packages.com.glide.glideobject.GlideDateTime();  


        11:       gDate.setValue(msDate);  


        12:       target.u_account_expires = gDate;  


        13:       gs.log('Setting the Account Expires date for ' + target.name + ' to ' + gDate);  


I get the same issue...



java.lang.SecurityException: Illegal attempt to access class 'com.glide.glideobject.GlideDateTime' via script
  Caused by error in Transform Script: 'onBefore' at line 10

  7: // Only convert AD accountExpires values that begin with 1 (ex. 0 represents never expires)
  8: if (s.charAt(0) == 1) {
  9: var msDate = new Packages.org.apache.poi.hpsf.Util.filetimeToDate(n);
==> 10: var gDate = new Packages.com.glide.glideobject.GlideDateTime();
  11: gDate.setValue(msDate);
  12: target.u_accountexpires = gDate;
  13: gs.log('Setting the Account Expires date for ' + target.name + ' to ' + gDate);    



I did see another post whereby it referenced creating a script include to do soem of the conversion that was called by the transform script... would this help?



Any ideas...?



Surely this has to be something simple as loads of people must want this functionality???   I'm sure someone has it working somewhere...?


The fix for me was to replace:


var gDate = new Packages.com.glide.glideobject.GlideDateTime();



with:


var gDate = new GlideDateTime();



Explanation: Packages Call Replacement Script Objects - ServiceNow Wiki