cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Morghan
Level: Powered On

Using IF expression to display custom card data

Hi everyone,

 

I piggy backed off a previous post of mine, but am thinking it went silent due to it already being marked as Solved. So creating a fresh post with my new question. The original post was https://powerusers.microsoft.com/t5/Using-Flows/Using-IF-expression-based-on-Choice-selection-email-...

 

Another question in relation to that same flow I am building.... It relates to the email body. I have another column in this "New Hire" process called "Using existing PC/laptop?" (true/false) - 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 into the email body; so the line in the email would read something like "New hire will be 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??

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Using IF expression to display custom card data

Hi @Morghan,

 

Thanks for updating.

If the column EmployeeName is of type Single line of text, then you just need to select it from the trigger.

Please take the following function for an example:

 

if(equals(triggerBody()?['Using_x0020_existing_x0020_PC_x0'],bool('True')),concat('will use existing pc from',triggerBody()?['EmployeeName']),'')

 

Note: I have changed the column type of EmployeeName to Single line of text.

Please take a try with it.

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Super User
Super User

Re: Using IF expression to display custom card data

@Morghan :

First, I am assuming that your data is stored in SharePoint.

 

Flow uses the internal name of a SharePoint column rather than the "display name"  The display name and the internal name are not always the same and will never be the same if there are spaces in a column name.  Your expression has spaces in the column name.

 

The easiest way to avoid this issue is to click back on Dynamic properties when building your expression and select the column.  That way, you're sure to have the correct syntax and name.

 

If you want to find a columns internal name, go to list settings and click on the column name.  The internal name will be at the end of the URL after "Field="

 

If this addresses your issue, please mark your post as Solved.

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Morghan
Level: Powered On

Re: Using IF expression to display custom card data

Hi @ScottShearer,

 

When you ask if I am storing my data in SharePoint, is the answer yes if I have all the columns from my expression existing in the List? The one currently in question (PreviousEmployeePC) is just hidden from view.

 

The Field is exactly what my first issue was (Thank you!). Once resolving that, I started receiving InvalidTemplate error in my flow: "cannot be evaluated because property 'Value' cannot be evaluated" -- I realized that I was trying to use a "VALUE" in my expression incorrectly, as it's a boolean. I've corrected that. Last thing is that I need to figure out how to display the value of "PreviousEmployeePC" (that is the internal name: Field=PreviousEmployeePC) in the email body. Here's the different variations I've tried but am getting invalid expression. I just need help with the syntax: 

 

if(equals(body('get_item')?['Using_x0020_existing_x0020_PC_x0'],true),'Will use existing PC from ['PreviousEmployeePC']','')
 
 
if(equals(body('get_item')?['Using_x0020_existing_x0020_PC_x0'],true),'Will use existing PC from ['PreviousEmployeePC.Value']','')
 
 
if(equals(body('get_item')?['Using_x0020_existing_x0020_PC_x0'],true),'Will use existing PC from ['PreviousEmployeePC']?[Value]','')
Super User
Super User

Re: Using IF expression to display custom card data

@Morghan :

 

Have you tried selecting the PreviousEmployeePC column from Dynamic properties while inside of your expression? 

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Morghan
Level: Powered On

Re: Using IF expression to display custom card data

@ScottShearer - I apologize, I know we briefly spoke about this in my last post... I am having a tough time wrapping my head around the difference of being inside or outside of the expression.  

 

 

Community Support Team
Community Support Team

Re: Using IF expression to display custom card data

Hi @Morghan,

 

I assume that the column “Using existing PC/laptop” is a Boolean column with value Yes/No.

How about the column that “a text box next to the toggle on/off control where you can enter the name of the previous user of that PC/laptop”? I guess that it is a person or group type column.

I have made the following test for your scenario, please check it for a reference.

Add the two columns “Using existing PS/laptop” (yes/no) and “EmployeeName” (person or group) in the list.

In the flow, input the following code in the email body to return EmployeeName when the selection for column “Using existing PC/laptop” column is True:

if(equals(triggerBody()?['Using_x0020_existing_x0020_PC_x0'],bool('True')),concat('will use existing pc from',triggerBody()?['EmployeeName']?['DisplayName']),'')

1.PNG2.PNG 

Please take it for a reference.

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
relight
Level: Power Up

Re: Using IF expression to display custom card data

thanks for the solution

Morghan
Level: Powered On

Re: Using IF expression to display custom card data

Hi @v-yamao-msft - thank you for the suggestion and assistance. Using the "people-picker"/display name column works. However, the problematic use-case I can think of, is that if the new hire (Employee B) is going to be using Employee A's old PC/laptop, and Employee A has been departed from the company for some time, Employee A will have been removed from O365 and would not appear in the people-picker list for DisplayName. The reason this is a use-case is because we may still have Employee A's old equipment out at a remote office which Employee B will be using. The question being: 

 

Can we just have the text value displayed? We'd like the ability to give the manager/user filling out the form the ablity to type whatever name they want.

 

To answer your questions:

 

"I assume that the column 'Using existing PC/laptop' is a Boolean column with value Yes/No." -- that is correct

 

"How about the column that 'a text box next to the toggle on/off control where you can enter the name of the previous user of that PC/laptop'? I guess that it is a person or group type column." -- If possible, I'd like to this to remain "Column type: Single line of text"

 

Everything else about your code would work for our use case except how can we get just plain text to be pulled? (what to put here in bold?)-

 

if(equals(triggerBody()?['Using_x0020_existing_x0020_PC_x0'],bool('True')),concat('will use existing pc from',triggerBody()?['PCEmployeeNameText']?['xxxxxxx']),'')

 

 

Does get_item need to be used?

Community Support Team
Community Support Team

Re: Using IF expression to display custom card data

Hi @Morghan,

 

Thanks for updating.

If the column EmployeeName is of type Single line of text, then you just need to select it from the trigger.

Please take the following function for an example:

 

if(equals(triggerBody()?['Using_x0020_existing_x0020_PC_x0'],bool('True')),concat('will use existing pc from',triggerBody()?['EmployeeName']),'')

 

Note: I have changed the column type of EmployeeName to Single line of text.

Please take a try with it.

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Morghan
Level: Powered On

Re: Using IF expression to display custom card data

Yes, that was it! And now that I see how the expressions of the dynamic fields are being written (using triggerBody when using Dynamic Content feature), this makes sense to me now. Thank you very much for your help.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (2,172)