
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 07:33 AM
Hello,
I wanted to create a transform map script that checked the target to see whether a boolean field was set to true. If set to true, then to ignore. If set to false, to carry on and update the record.
I created an onBefore script with the following:
var dup = new GlideRecord('sys_user');
dup.addQuery('u_duplicate_record', true);
dup.query();
if (dup.next()) {
ignore = true;
}
However, its ignoring all records! Can someone point out what I have done wrong please?
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 08:06 AM
Hi,
you can use onBefore transform script since you already know the target record
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(target.u_duplicate_record.toString() == 'true')
ignore = true;
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 08:01 AM
if you have a single record in the sys_user table with the u_duplicate_record is true it will ignore all records.
With every record you you check if there is a sys_user record that has duplicate = true then you ignore. I think you want to query if the target record has duplicate = true then ignore.
I would change the script from on before to run during transform (the one on the transform form itself).
change the script to:
ignore = target.u_duplicate_record;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 08:06 AM
Hi,
you can use onBefore transform script since you already know the target record
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(target.u_duplicate_record.toString() == 'true')
ignore = true;
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 08:38 AM
That seems to have worked well. Thank you so much for your help