cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DavidLozzi
Advocate II
Advocate II

Why isn't this If working?

Trying the following if statement. When I write importance out to anothe field, it's 1 or 2 (depending on importance of email). But trying this expression in a field it errors saying invalid

 

if(triggerBody()?['Importance'] = 2,true,false)
 
image.png

 

Lozzi
slalom
1 ACCEPTED SOLUTION

Accepted Solutions
Mike2500
Continued Contributor
Continued Contributor

I just experienced something similar. I couldn't get the most basic if statement to work in the expression box. the following threw the same error you reported:

 

if(1=2,1,2)

 

But the following worked:

 

if(equals(1,2),1,2)

 

So, perhaps try:

 

if(equals(triggerBody()?['Importance']),2),true,false)

 

 

Edit: Of course, Flow is using Workflow Definition Language. For a moment I had gotten confused and was using PowerApps syntax. the reference for WDL functions is here:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#functions

 

So, in PowerApps, 1=1 is fine, but in Flow, we should use equals(1,1)

 

View solution in original post

3 REPLIES 3
v-micsh-msft
Community Support
Community Support

Hi @DavidLozzi,

 

Take a try to format the importance with int() function:

if(int(triggerBody()?['Importance']) = 2,true,false)

See if this would make any difference.

 

Regards,

Michael

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

No dice, 

 

if(int(triggerBody()?['Importance'])=2,true,false)
Lozzi
slalom
Mike2500
Continued Contributor
Continued Contributor

I just experienced something similar. I couldn't get the most basic if statement to work in the expression box. the following threw the same error you reported:

 

if(1=2,1,2)

 

But the following worked:

 

if(equals(1,2),1,2)

 

So, perhaps try:

 

if(equals(triggerBody()?['Importance']),2),true,false)

 

 

Edit: Of course, Flow is using Workflow Definition Language. For a moment I had gotten confused and was using PowerApps syntax. the reference for WDL functions is here:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#functions

 

So, in PowerApps, 1=1 is fine, but in Flow, we should use equals(1,1)

 

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Automate User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (26,764)