- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:10 AM
Hello,
I'm having some issues with a transform map script, basically unless the compliance state is Compliant it needs to be ignored and if you can also you can add in too if the target assigned_to is not active to also ignore.
Thanks in advance! 🙂
//OnStart
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_compliancestate != 'compliant') {
ignore = true;
}
})(source, map, log, target);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:19 AM - edited 09-15-2023 02:23 AM
Hi @Andrew_TND,
You need to use onBefore, not onStart.
onBefore is evaluated before each row, onStart, before anything happens.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_compliancestate != 'compliant' && !target.assigned_to.active) {
ignore = true;
}
})(source, map, log, target);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:19 AM - edited 09-15-2023 02:23 AM
Hi @Andrew_TND,
You need to use onBefore, not onStart.
onBefore is evaluated before each row, onStart, before anything happens.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_compliancestate != 'compliant' && !target.assigned_to.active) {
ignore = true;
}
})(source, map, log, target);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:22 AM
onStart will run only once.
I believe you need to use onBefore script which will run for every row of import set.
for extra condition add this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_compliancestate != 'compliant' && target.assigned_to.active.toString() != 'active') {
ignore = true;
}
})(source, map, log, target);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader