Hi there
I'm using the first() expression in a flow when it comes to Approve/Reject because I want to avoid Apply Each. The expression I used is this:
and this is the error message I got:
Unable to process template language expressions for action 'Approved_or_Denied' at line '0' and column '0': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#first for usage details.'.
I've successfully used first(body('Freelancer_Approval')?['responses'])?['comments'] to get the comments, but I'm unsure as to where I'm going wrong here with the response. Any help would be awesome.
I'm using it in a condition as in if EXPRESSION is equal to Approve; if yes, do that, if no then do that.
Solved! Go to Solution.
For anyone else who has this issue, I've resolved it. First by adding a compose (thanks to @MarconettiMarco for the brain wiggle) with the following expression:
outputs('Freelancer_Approval')?['body/responses'][0]['approverResponse']
I then used the output of the compose in the condition to be equal to Approve, and everything ran as expected!
Hello @smather ,
in the "Create an approval" action you should be able to select the "Approve/Reject - First to Respond:
In that way you can easily avoid the Apply to each control.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
BR,
Marco
That is the one I already have, but it still forces my flow to have an Apply Each if I use the field directly from Approve/Reject, which is why I've gone this route.
ok, if you can, share the output of the action "Freelancer_Approval" from where you want to grab the first value.
BR,
Marco
Not sure what you mean, but hopefully the screenshot helps?
the expression in the condition is first(body('Freelancer_Approval')?['body/responses'])
Hi @smather
you should be able to run the flow and get the output from the "Freelancer_Approval" action.
Anyhow, yon can also, after the "Freelance_Approval" action, add the "Compose" action and insert the following expression:
first(variables('Freelancer_Approval'))
then you have to add "Parse JSON" action using the Compose output value. In this way you should be able to get all the values from the first item in order to add them in the next actions.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
BR,
Marco
Hi @MarconettiMarco -- just an additional clarification question, sorry! In the Parse JSON, what's the required schema?
Hi @smather ,
keep the outputs from the Compose action (so first you need to run the flow):
then copy and paste it into the "Generate from Sample" function in the "Parse JSON" action (the Content must be the "Compose" outputs:
and click "Done":
So in the next Actions/Controls you should be able to get the value you want.
Please let me know.
BR,
Marco
Thank you! But it seems to spit out an error when I try to run it:
Flow save failed with code 'InvalidVariableOperation' and message 'The inputs of workflow run action 'Compose' of type 'Compose' are not valid. The variable 'Freelancer_Approval' must be initialized before it can be used inside action 'Compose'.'.
Please share the screenshots.
BR,
Marco
This is what the flow looks like in its entirety
For anyone else who has this issue, I've resolved it. First by adding a compose (thanks to @MarconettiMarco for the brain wiggle) with the following expression:
outputs('Freelancer_Approval')?['body/responses'][0]['approverResponse']
I then used the output of the compose in the condition to be equal to Approve, and everything ran as expected!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
66 | |
22 | |
16 | |
16 | |
11 |
User | Count |
---|---|
133 | |
44 | |
32 | |
32 | |
28 |