Overall, I have a logic app that looks like this:
The uploaded blob CSVs will have different structures, but will always contain a column that I do not want to send out to the recipients. It's a distribution list that I will use to compose the email (already achieved this part), but I'm having trouble handling this for all cases. My "Select" and "Create CSV" activities (to ultimately exclude the distribution list) are hardcoded in for a specific structure. Like so:
How can I handle this for all cases where something like a "DistributionList" column always exists but others are unknown. (I'm already handling the parsing of the JSON dynamically by just inserting "{}" for the schema)
You can use Execute JavaScript Code to remove the Distribution List using below design:
var ri_tst_ar = workflowContext.actions.Parse_JSON.outputs.body;
var ri_out = ri_tst_ar.map(function(rith) {
var tst = {};
for (var ri in rith) {
if (ri !== "DistributionList") {
tst[ri] = rith[ri];
}
}
return tst;
});
return ri_out;
Then:
Output:
Distribution List is removed using the code.