
Announcements
Hi, I am running an API call where I am anticipating a certain string being in one of the keys of the response. For instance, in this image I am expecting the string "invoice_multi_kit" to be the key of the webhookEvent pipeline_records object:
I then want to run a child flow for every instance that "invoice_multi_kit" appears in this key. The way I have been trying to do this is by putting the expected string ("invoice_multi_kit") in a variable called SchemaName and then running an apply to each on the expression:
I keep getting an error in the apply to each stating:
The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body/pipeline_records']?[variables('SchemaName')]' is of type 'String'. The result must be a valid array.
and when I change my SchemaName to be an array, I get the error:
Unable to process template language expressions for action 'Apply_to_each' at line '0' and column '0': 'The template language expression 'triggerOutputs()?['body/pipeline_records']?[variables('SchemaName')]' cannot be evaluated because property '[
"invoice_multi_kit"]' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'
Is there a way to fix this or a better way to approach this?
Can you try adding a Compose to check if the following expression is true or false. That should tell you if the property exists or not.
empty(triggerOutputs()?['body/pipeline_records/invoice_multi_kit'])
If that works, then you could consider adding a Trigger Condition as below, so the flow only runs if it exists.
@equals(empty(triggerOutputs()?['body/pipeline_records/invoice_multi_kit']), false)
For iterating over multiple instances of invoice_multi_kit, can you get a response that has more than one instance and then click on Show raw outputs so we can see the exact JSON returned.