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 / Using IF expression ba...
Power Automate
Unanswered

Using IF expression based on Choice selection - email body

(0) ShareShare
ReportReport
Posted on by 209

Hello,

 

I am creating a New Employee Hire form/flow and there's a column called "Department" (Choice). If the user selects "Accounting", I'd like to display specific text within the email body that is being triggered. If anything else is selected, I'd like to NOT show any special text. How can I accomplish this? I have tried several variations of the expression but am told it's incorrect. Am I close? -

 

if(equals('Department.Selected.Value',Accounting),'Grant edit permissions to vHUB's Accounting libraries','')

Categories:
I have the same question (0)
  • Morghan Profile Picture
    209 on at

    Another related question would be how to display specific text based on true/false values for certain columns?

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Morghan:

     

    I ran a test using a For a Selected Item trigger and a Get Item action and the following worked for me:

    if(equals(body('get_item')?['Department']?['Value'],'Accounting'),'Grant edit permissions to vHUB's Accounting libraries','')

     

    In the example you posted, you just referenced the column name and Flow doesn't understand that.  Select the value that you want to reference in your expression from Dynamic properties - switch back to Dynamic properties while you are in your expression, select the value you want and then switch back to the expression and continue.  That way, Flow will add what it needs in order to grab that value from the trigger or action that is supplying the value.

     

    This may sound a little confusing - it you need more help, please post here.

     

    If this answers your question, please mark your post as Solved.

     

    Scott

     

     

  • Verified answer
    ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Morghan:

     

    You can use an If expression to test for the value of a true false column:

     

    if(equals(body('get_item')?['TrueFalseColumn'],true),'I am true','I am not true')

     

    Please note that there are no quotes around true - it is not a string.

     

    If this answers your question, please mark your post as solved.

     

    Scott

  • v-yuazh-msft Profile Picture
    on at

    Hi @Morghan,

     

    Could you please share a screenshot of the configuration of your flow?

    What is the trigger in your flow?

     

    Best regrads,

    Alice

  • Morghan Profile Picture
    209 on at

    Hi @ScottShearer,

     

    Thank you for reply. I apologize for the delayed response. Taking your example, here is what my true false expression looks like:

     

    if(equals(body('get_item')?['MRI'],true),'MRI','')

     

    However, I am still receiving "Invalid Expression" error in Flow. If it helps, here is a screenshot of what I am trying to do. I am trying to print the text "MRI" in this email body if the value of the "MRI" column is TRUE,  else do not print anything:

     

    flow-screenshot-1.jpgI am confused on how the 'get_item' works (in regards to both of my questions). I tried playing with it a little bit but am lost. Am I supposed to just be adding a Get Item action before the email action?

  • Morghan Profile Picture
    209 on at

    I apoligize. I provided the incorrect error. I WAS getting "Inavlid Expression" but fixed that. The error I am getting at this time when SAVING my flow after adding the expression is: "The template validation failed: 'The action(s) 'get_item' referenced by 'inputs' in action 'Send_an_email_to_Vestar_IT_and_itSynergy' are not defined in the template.'."

     

    @v-yuazh-msft, @ScottShearer

     

    Thanks again for your assistance.

  • Morghan Profile Picture
    209 on at

    OK, @ScottShearer - I am making progress.. I was able to get the true false columns figured out (thank you). I am now just stuck on why the following does not work:

     

    if(equals(body('get_item')?['Department']?['Value'],'Accounting'),'Grant edit permissions to vHUB's Accounting libraries','')
     
    I am receiving "The expression is invalid" error:
     
    2019-01-14_14-57-39.jpg
  • Community Power Platform Member Profile Picture
    on at

    Hi @Morghan,

     

    It looks like the ' is the problem from this part:

     

    vHUB's

     

    You can escape this. Try the following as an expression:

     

    if(equals(body('get_item')?['Department']?['Value'],'Accounting'),'Grant edit permissions to vHUB\'s Accounting libraries','')
  • Morghan Profile Picture
    209 on at

    Even when commenting out, I get Invalid Expression. I ended up just removing it all together to read: 

     

    if(equals(body('get_item')?['Department']?['Value'],'Accounting'),'Grant edit permissions to vHUBs Accounting libraries','') 

    and verified it works as expected. thank you all.

  • Morghan Profile Picture
    209 on at

    Hi @Anonymous, @v-yuazh-msft and @ScottShearer -

     

    Another question in relation to this same flow I am building.... It relates to the same email body. I have another column in this "New Hire" process called "Using existing PC/laptop?" - In my custom form, I have it set to where if that is TRUE, the form will then display a text box next to the toggle on/off control where you can enter the name of the previous user of that PC/laptop. My goal is to, if "Using existing PC/laptop?" is TRUE, display the name that was entered into that text box; so the line in the email would read something like "Using PC/laptop that belonged to: <name>". The text box in the form is called "PreviousEmployeePC" -- I tried using the following expression (which returns valid, but does not print anything when testing): 

     

    if(equals(body('get_item')?['Using existing PC/Laptop?']?['Value'],true),'Will use existing PC from PreviousEmployeePC.Value','')

     

    Am I close??

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard