Skip to main content

Notifications

Power Automate - General Discussion
Answered

How to concatenate HTML if Approval Response variable has text?

(0) ShareShare
ReportReport
Posted on by 299

I am using the "Start and wait for an approval" connector within my custom flow.  I am also adding a response variable inside an send mail v2 connector, so that any responses from the approver get sent to the submitter who filled out the form.  But I would like to concatenate HTML before the response, only if there's a response from the approver.  Is this possible to setup a condition like this from within Power Automate?

 

Something like this 

 

(if there is a response from the approver)

<p>the part before the response</p>

The actual response

 

 

  • Jcook Profile Picture
    Jcook 7,770 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    @kensley 

     

    Sorry.. That is my fault.

    The correct expression would be:

    if(empty(variables('approver_comment')),'','<h2>A message by the Approver</h2>')

    Since empty() returns true if the value is empty. 

  • Jcook Profile Picture
    Jcook 7,770 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    Hi @kensley 

     

    Sorry but could you post a screenshot of the expression inside the email action?

  • CU09091757-0 Profile Picture
    CU09091757-0 299 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    Thanks for the help! When I put the following code into my expression field, and click "ok" to then add it into the body area of my "Send an email V2" Connector...

     

     

    if(equals(empty(variables('approver_comment'))),true,'','<h2>A message by the Approver</h2>')

     

     

    PA complains before sending that e-mail out and says....

     

     Unable to process template language expressions in action 'Accept_-_Send_an_email_(V2)_-_Requester' inputs at line '1' and column '48999': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '4' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

     

    Sorry for any bonehead mistakes I'm making.

  • Jcook Profile Picture
    Jcook 7,770 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    @kensley 

     

    What error are you seeing?

  • CU09091757-0 Profile Picture
    CU09091757-0 299 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    @Jcook, many many thanks on that example you provided. Where can I go to learn how to do what you just did, but for variables? Where can I learn the syntax? I'm trying to get a variable into an if condition, as an expression, for the body of my email. But I feel that I am failing because every time I run my flow, it causes an error.

     

    For example, this fails me:

    if(equals(empty(variables('approver_comment'))),true,'','<h2>A message by the Approver</h2>')

     

     

    Thanks for any tips on variable usage!

  • Jcook Profile Picture
    Jcook 7,770 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    Hello @kensley 

     

    Yes you can use an IF expression right inside the email.

    Try:

    if(equals(empty(<Your Response>)),true,’ ‘,’the part before the response’)

     

    this expression is saying: if the response is empty put nothing, if the response is NOT empty put the part before the response.

     

    please note the 2 single quotes after true, do not need to have a space in between. But I added a space to be easily read on this post.

  • Verified answer
    Rahber Profile Picture
    Rahber 1,935 on at
    Re: How to concatenate HTML if Approval Response variable has text?

    Initialize a variable and then in the condition of approvals you can add text to that variable and the outcome variable only if there was a response. If the response is no the variable will still be empty as i initialized it as empty

     

    Please see the image below

    Capture.PNG

    Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

    Thanks,
    Rahber

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard