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
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.
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, 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!
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.
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
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