How to resolve LDAP transform script error for Active Directory date fieldsIssue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Troubleshoot an LDAP transform script error when importing Active Directory (AD) date fields, such as account expiration dates, to the User [sys_user] table. When implementing a transform script to convert AD date fields, the script fails with the following error: "Unable to format undefined using format string yyyy-MM-dd HH:mm:ss for field u_windows_account_expiry_date" Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All supported releases Cause<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The target field has a Date Format defined, but the transform script is not passing a string that can be formatted as a date. This occurs when the custom script is pasted below the default function instead of replacing it: answer = (function transformEntry(source) { // Add your code here return ""; // return the value to be put into the target field})(source); The default function returns a blank value, which causes the error. The custom script is ignored because it appears after the default function's return statement. Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } When creating the transform script, replace the entire default script with your custom script. Do not paste the custom script below the default function. Example configuration The following example imports an AD account expiration date field to a custom date field on the User form: Create a date/time field on the User form for the expiration date.Configure the LDAP server: Go to your LDAP server record.In the Attributes section, add your AD expiry field name (for example, accountexpires).Select Save. Configure the transform map: Go to your users transform map.Select New to add a field map.In the Target field, select your new date field.In the Date Format field, enter yyyy-MM-dd HH:mm:ss.Set Use Source Script to true. Replace the default script with a script similar to the following example: //Expiry Date/Time//answer = (function transformEntry(source) {// For update set// Add your code here// This function converts the UTC date/time to local date/timefunction getLocalTimeZoneDateTime(dateTimeUTC) {var gdt = new GlideDateTime(dateTimeUTC);return gdt.getDisplayValueInternal();}var dtUtil = new DateTimeUtils();if (source.u_accountexpires === undefined) {// set a blank value if the source is 'undefined'target.setValue(u_expiry_date,'');} else if (source.u_accountexpires != 0) {// convert the date from int8 format to GlideDateTime in UTCvar expiresUTC = dtUtil.int8ToGlideDateTime(source.u_accountexpires);// convert the GlideDateTime in UTC to Local TimeZonevar expiresLocal = getLocalTimeZoneDateTime(expiresUTC.toString());//log.info("ExpiresLocal: " + expiresLocal);// Set the value to the Local Time Zone valueanswer = expiresLocal;} else {// set a blank value if the source is anything else.target.setValue("u_expires", '');}//})(source); Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } LDAP Transform Dates (ServiceNow Community) Original script source for converting AD date fields