Instead of iterating/filtering over items to create a new list of forms, fields or other objects, it literally takes 2 modules: The first to transform the object into JSON, the second JSONata.
In JSONata you can filter / map (transform) and many other things.
https://tryjsonata.org for online learning/testing - just slap the JSON in here and work out the set of functions.My use case: I have a data CSV to import, where each row has a column that is a dropdown in WF. So I want to check:
- remove any WF option that is not in the new data file
- add any option that is not yet in WF.
- The JSONata expression is this:
(
$importList := {{31.json}}; /* from a previous transformToJSON module */
$existing := {{30.json}}; /* from a previous transformToJSON module */
$oktokeep := $filter( $existing, function ( $v ) { $v.value in $importList ? true:false });
$toadd:= $map($filter( $importList , function ($v){
( ($v in $existing.value) ? false :true )
}), function ($v) { { "objCode": "POPT", "value": $v, "label": $v} });
$append($toadd,$oktokeep)
)