- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 02:47 AM
Hi,
I am struggeling with a transform script and I hope you can help me. The situation is that during an LDAP consolidation project two different LDAPs need to be imported into ServiceNow. The only possible coalesce attribute is email, however some accounts from the old LDAP should not be overwritten by the new LDAP import. All records that only exist in the new LDAP should, always be updated. I added a new attribute "LDAP_tempuser" to identify accounts that should be overwritten and I set up the following onBefore script to restrict the update process:
if (action == "update" && target.ldap_server != "newLDAP" && target.u_ldap_tempuser == false) {
ignore = true;
}
My expectation is that:
- If all conditions within the if clause are fulfilled, the record is ignored
- If any of the conditions within the if clause is not fulfilled, the existing record is updated
However, the transform ignores all records, regardless of the if statement above and I cannot see why. Any ideas?
The attached screenshot shows the intended logical flow if that helps.
Thanks in advance for your help!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 03:24 AM
Hey Martin,
target.ldap_server is a reference field so "newLDAP" actually needs to be the sys_id of the newLDAP server you have created.
var ldap_server = "32424a11dbba22002686da94ce96194b"; // newLDAP
if (action == "update" && target.ldap_server != ldap_server && target.u_ldap_tempuser == false) {
ignore = true;
}
Right now, nothing is being inserted because that field would never equal "newLDAP".
Cheers,
James

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 03:24 AM
Hey Martin,
target.ldap_server is a reference field so "newLDAP" actually needs to be the sys_id of the newLDAP server you have created.
var ldap_server = "32424a11dbba22002686da94ce96194b"; // newLDAP
if (action == "update" && target.ldap_server != ldap_server && target.u_ldap_tempuser == false) {
ignore = true;
}
Right now, nothing is being inserted because that field would never equal "newLDAP".
Cheers,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 04:05 AM
Hi,
thank you for your reply. Sorry, I should have mentioned that "newLDAP" was just anonymized for the string value of the actual LDAP server name of the new LDAP server. Does it have to be the sys_id or can it also be the string value?
And even if i take the LDAP server condition out of the if statement and just have
if (action == "update" && target.u_ldap_tempuser == false) {
ignore = true;
}
the records are still ignored instead of updated. So I was wondering if the && operators within if statements of transform scripts are generally possible.
I also tried to create the new variable "ldap_server" with the sys_id and include that instead of the string value in the script but still no change. All records are ignored by the onBefore Script.
Thanks and kind regards,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2017 11:51 PM
Thanks James! I tried again by changing to the sys_id of the LDAP server and it worked now!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 04:15 AM
Hello Martin,
Have you checked the transform logs, there you will find the reason why it is being ignored.