Hi everyone,
You may keep mapping file of source and target fields. For instance, if your create the array of mapping among source and target fields (e.g. [sourcefield, targetfield]) as follows:
{
“fields_map”: [
[
“source_field_1”,
“target_1”
],
[
“source_field_2”,
“target_2”
]
]
}
then you can use the following statement in the mapper:
$.mapKeys((value, key) => $fields_map.find(x => x[0].toLowerCase() == key.toLowerCase()) !=null ? $fields_map.find(x => x[0].toLowerCase() == key.toLowerCase())[1] : key)
If you want to have only mapped fields in the output, you can set filtering with mapper snap as follows:
$.filter((value, key) => ($fields_map.length > 0 ? $fields_map.filter(x => x[1].toLowerCase() == key.toLowerCase()).length>0 : true))
$fields_map can be generated by reading values from CSV file and by using one additional mapper snap.
Regards,
Lazo