How to validate Target data after transforming source data using Transform map?

Suggy
Giga Sage

Once the data is loaded and transformed using Transform map, I need to validate if all the fields are mapped.

Below is the sample data

NameDescriptionAssigned toLocation
CostaTest descriptionAndrew Och 
AdmondTest description Atlanta
FloraTest description  

 

I need to ensure the 2 reference fields 'Assigned to' and 'Location' is mapped in target table once the data transformation is done.

I have written two OnAfter transform scripts like this:

1.

if (target.u_assigned_to == '')
{  
        status_message = 'Assigned To field is not mapped';
}

2.

if (target.u_location == '')
{  
        status_message = 'Location field is not mapped';
}
 
but the result is like this:
ttt.png
As you see above, for the 3rd record above [Row=2], both Assigned To and Location was empty in source data, but in the comment only 'Assigned To field is not mapped' is printed, but 'Location field is not mapped' is NOT PRINTED.
 
Why? How to achieve it?
1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hi @Suggy,

 

It's because you are overwriting the value, not appending to it.

Why not have a single onAfter script and use something like below:

status_message  = [];
if (target.u_assigned_to == '')
{  
        status_message.push('Assigned To field is not mapped');
}

if (target.u_location == '')
{  
        status_message.push('Location field is not mapped');
}
status_message  = status_message.join('\n');

View solution in original post

2 REPLIES 2

James Chun
Kilo Patron

Hi @Suggy,

 

It's because you are overwriting the value, not appending to it.

Why not have a single onAfter script and use something like below:

status_message  = [];
if (target.u_assigned_to == '')
{  
        status_message.push('Assigned To field is not mapped');
}

if (target.u_location == '')
{  
        status_message.push('Location field is not mapped');
}
status_message  = status_message.join('\n');

Hi @James Chun Yes that works. Thank you soo much 🙂