Active Directory の日付フィールドの LDAP 変換スクリプトエラーを解決する方法Issue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } アカウントの有効期限などの Active Directory (AD) 日付フィールドをユーザー [sys_user] テーブルにインポートする際の LDAP 変換スクリプトエラーをトラブルシューティングします。 AD 日付フィールドを変換する変換スクリプトを実装すると、スクリプトが次のエラーで失敗します。 "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: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } サポートされているすべてのリリース Cause<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } ターゲットフィールドに日付形式が定義されているが、変換スクリプトが日付として書式設定できる文字列を渡していない。 これは、カスタムスクリプトを置換するのではなく、デフォルトの関数を貼り付け以下した場合に発生します。 answer = (function transformEntry(source) { // Add your code here return ""; // return the value to be put into the target field})(source); デフォルトの関数は空白の値を返すため、エラーが発生します。カスタムスクリプトは、デフォルト関数の return ステートメントの後に表示されるため、無視されます。 Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } 変換スクリプトを作成するときは、デフォルトスクリプト全体をカスタムスクリプトに置き換えます。デフォルト関数の下にカスタムスクリプトを貼り付けないでください。 構成例 次の例では、AD アカウントの有効期限フィールドをユーザーフォームのカスタム日付フィールドにインポートします。 ユーザーフォームに有効期限の日付/時刻フィールドを作成します。LDAP サーバーを設定します。 LDAP サーバーレコードに移動します。属性 セクションで、AD 有効期限フィールド名 (accountexpires など) を追加します。[保存] を選択します。 変換マップを構成します。 ユーザー変換マップに移動します。[ 新規 を選択してフィールドマップを追加します。[ ターゲット] フィールドで、新しい日付フィールドを選択します。[ 日付形式 フィールドに「yyyy-MM-dd HH:mm:ss」と入力します。ソーススクリプトを使用 を true に設定します。 デフォルトのスクリプトを次の例のようなスクリプトに置き換えます。 //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: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } LDAP 日付を変換 (ServiceNow コミュニティ) AD 日付フィールドを変換するための元のスクリプトソース