web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Approve/ Reject - Firs...
Power Automate
Unanswered

Approve/ Reject - First expression

(0) ShareShare
ReportReport
Posted on by 56

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:  

 

first(body('Freelancer_Approval')?['body/responses'])

 

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. 

Categories:
I have the same question (0)
  • MarconettiMarco Profile Picture
    3,812 Super User 2024 Season 1 on at

    Hello @smather ,

    in the "Create an approval" action you should be able to select the "Approve/Reject - First to Respond:

    MarconettiMarco_0-1656339057772.png

     

    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

     

     

  • smather Profile Picture
    56 on at

    Hi @MarconettiMarco 

     

    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. 

  • MarconettiMarco Profile Picture
    3,812 Super User 2024 Season 1 on at

    ok, if you can, share the output of the action "Freelancer_Approval" from where you want to grab the first value.

     

    BR,

    Marco

  • smather Profile Picture
    56 on at

    Hi @MarconettiMarco 

     

    Not sure what you mean, but hopefully the screenshot helps? 

     

    smather_0-1656339722552.png

     

    the expression in the condition is first(body('Freelancer_Approval')?['body/responses'])

  • MarconettiMarco Profile Picture
    3,812 Super User 2024 Season 1 on at

    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

  • smather Profile Picture
    56 on at

    Hi @MarconettiMarco -- just an additional clarification question, sorry! In the Parse JSON, what's the required schema? 

  • MarconettiMarco Profile Picture
    3,812 Super User 2024 Season 1 on at

    Hi @smather ,

    keep the outputs from the Compose action (so first you need to run the flow):

    MarconettiMarco_0-1656403202101.png

     

    then copy and paste it into the "Generate from Sample" function in the "Parse JSON" action (the Content must be the "Compose" outputs:

     

    MarconettiMarco_1-1656403303543.png

    and click "Done":

    MarconettiMarco_2-1656403398683.png

     

    So in the next Actions/Controls you should be able to get the value you want.

    Please let me know.

     

    BR,

    Marco

     

     

  • smather Profile Picture
    56 on at

    Hi @MarconettiMarco 

     

    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'.'.

     
    I put the Compose action directly before the condition
  • MarconettiMarco Profile Picture
    3,812 Super User 2024 Season 1 on at

    Please share the screenshots.

     

    BR,

    Marco

  • smather Profile Picture
    56 on at

    This is what the flow looks like in its entirety 

     

    smather_0-1656404675125.png

    smather_1-1656404767591.png

    smather_2-1656404826417.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard