- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2014 01:27 PM
When importing expirydate from LDAP to sys_user table - I am obtaining an incorrect date. If user expiry date in Active directory is 31/12/2014 the date being displayed on the user form on ServiceNow is 01/01/2015 I was told that It is being imported on GMT and I need to convert it to EST. Can I do it directly on the date field?
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2014 06:24 AM
It will only affect that one particular variable and field. Your script is not quite right though as you need to modify the timezone for your gDate variable. You need to put:
//converting GMT to Canada/Eastern
var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");
gDate.setTZ(tz);
...right after you initialize the variable and before you assign the date to it. You should end up with:
var gDate = Packages.com.glide.glideobject.GlideDateTime();
//converting GMT to Canada/Eastern
var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");
gDate.setTZ(tz);
gDate.setValue(msDate);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2014 08:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2014 05:30 AM
No this won't affect anywhere, This will affect target.date, that is only date field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2014 06:24 AM
It will only affect that one particular variable and field. Your script is not quite right though as you need to modify the timezone for your gDate variable. You need to put:
//converting GMT to Canada/Eastern
var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");
gDate.setTZ(tz);
...right after you initialize the variable and before you assign the date to it. You should end up with:
var gDate = Packages.com.glide.glideobject.GlideDateTime();
//converting GMT to Canada/Eastern
var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");
gDate.setTZ(tz);
gDate.setValue(msDate);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2014 07:26 AM
Jim, the field u_expiry_date should be date/time type or date.
I have it as 01/01/2015 00:00:00 - which is date/time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2014 07:43 AM
After running again - scheduled import from LDAP. It 's still displaying the value with an additional day.
// Updates the SN Account Expires field with the accountExpires value from AD
// Active Directory stores the accountExpires date as an Integer8 which must be converted into DateTime for SN
var n = source.u_accountexpires;
var s = n.toString();
// Only convert AD accountExpires values that begin with 1 (ex. 0 represents never expires)
if (s.charAt(0) == 1) {
var msDate = new Packages.org.apache.poi.hpsf.Util.filetimeToDate(n);
var gDate = new Packages.com.glide.glideobject.GlideDateTime();
//converting GMT to Canada/Eastern
var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");
gDate.setTZ(tz);
//converting GMT to Canada/Eastern
gDate.setValue(msDate);
target.u_expiry_date = gDate;
gs.log('Setting the Account Expires date for ' + target.name + ' to ' + gDate);
}
// Clear the SN Account Expires date if the accountExpires date is no longer set in AD
else if (!target.u_expiry_date.nil()) {
target.u_expiry_date = '';
gs.log('Updating the SN Account Expires date for ' + target.name + ' to Never');
}