Transform map script help

Andrew_TND
Mega Sage
Mega Sage

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);

 

 

 

1 ACCEPTED SOLUTION

Peter Bodelier
Giga Sage

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.

View solution in original post

2 REPLIES 2

Peter Bodelier
Giga Sage

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.

Ankur Bawiskar
Tera Patron
Tera Patron

@Andrew_TND 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader