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

If Logic in a Flow

Hello,

I am trying to use an if formula to determine what a field will be set to in one of my flows. My formula does not seem to be working and I can't figure out why. Do the if statements need to written a different way?

 

Right now my formula is:

 

If(triggerBody()?['Term_Sheet_Needs_to_be_Generated__c'] = true, "Need term sheet", If(triggerBody()?['Milestones__c'] = true, "Milestones need to be approved", If(triggerBody()?['Term_Sheet_Generated__c'] = true, "Waiting on App Submission", If(triggerBody()?['Info_Ready_to_be_Reviewed__c'] = true, "Documents Need to Generated", If(triggerBody()?['Docs_Created__c'] = true, "Out for Signing", If(triggerBody()?['Legal_Agreement_Process_Done__c'] = true, "Completed", "Waiting for Materials"))))))
2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: If Logic in a Flow

Hi chartergrowth,

 

You may take the following function for a reference:

if(equals(triggerBody()?['Approved_x003f_'],bool('True')),'need term sheet',if(equals(triggerBody()?['Test2'],bool('True')),'need to be approved','completed'))

 

In my case, the columns Approved and Test2 are Boolean type(Yes/No). When a new item is created, if the value in the Approved column is false, in Test2 column is true, the function will return “need to be approved”.

3.PNG

 

Please adjust the function according to your scenario and try again with it.

 

Please feel free reply if you need more help.

 

Best regards,
Mabel Mao

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

Dual Super User
Dual Super User

Re: If Logic in a Flow

@chartergrowth

There is a typo in one of the subexpressions

If(equeals(triggerBody()?['Term_Sheet_Generated__c']...

If this is not the problem I would recommend to start with a simple expression (one IF), save, and add the rest of the IFs one by one. I know it takes a lot of time to do it this way, but sometimes when an expression is so complex it is the only way to identify the problem.

Hope this helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





View solution in original post

9 REPLIES 9
Dual Super User
Dual Super User

Re: If Logic in a Flow

Hi!

Try to use

equals(triggerBody()?['Term_Sheet_Needs_to_be_Generated__c'], true)

instead of 

triggerBody()?['Term_Sheet_Needs_to_be_Generated__c'] = true

 

I would also substitute double quotes by single quotes

Hope it helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





chartergrowth
Level: Powered On

Re: If Logic in a Flow

Thanks for your suggestion. I changed my formula to:

 

If(equals(triggerBody()?['Term_Sheet_Needs_to_be_Generated__c'], true), 'Need term sheet', If(equals(triggerBody()?['Milestones__c'], true), 'Milestones need to be approved', If(equals(triggerBody()?['Term_Sheet_Generated__c'], true), 'Waiting on App Submission', If(equals(triggerBody()?['Info_Ready_to_be_Reviewed__c'], true), 'Documents Need to Generated', If(equals(triggerBody()?['Docs_Created__c'], true), 'Out for Signing', If(equals(triggerBody()?['Legal_Agreement_Process_Done__c'], true), 'Completed', 'Waiting for Materials')))))

 

Unfortunately, it is still not working. Do you have any more suggestions?

 

Thank you!

Dual Super User
Dual Super User

Re: If Logic in a Flow

@chartergrowth

 

Can you provide more details about the error? Can you save the flow with such expression declared? Can you execute the flow? IF so, is the problem related to the fact the expression always provides the same result no matter the input?

BR 





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





Community Support Team
Community Support Team

Re: If Logic in a Flow

Hi chartergrowth,

 

You may take the following function for a reference:

if(equals(triggerBody()?['Approved_x003f_'],bool('True')),'need term sheet',if(equals(triggerBody()?['Test2'],bool('True')),'need to be approved','completed'))

 

In my case, the columns Approved and Test2 are Boolean type(Yes/No). When a new item is created, if the value in the Approved column is false, in Test2 column is true, the function will return “need to be approved”.

3.PNG

 

Please adjust the function according to your scenario and try again with it.

 

Please feel free reply if you need more help.

 

Best regards,
Mabel Mao

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

chartergrowth
Level: Powered On

Re: If Logic in a Flow

Thank you for your suggestion but it still will not work for me even after I changed my formula.

I keep getting an error message that says "The expression is invalid". It will not let me even save the flow if I use the formula.

I have tested the flow without the function and it works perfectly. 

Thanks!

 

Community Support Team
Community Support Team

Re: If Logic in a Flow

Hi chartergrowth,

 

What’s your data source? What are the column types? Please show more details about the data source.

 

Please show me the code you are using on your side. And if possible, please share a screenshot of your flow.

 

Please make sure all the columns name are correctly used in your code.

 

Best regards,

Mabel Mao        

 

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.
chartergrowth
Level: Powered On

Re: If Logic in a Flow

The data source is Salesforce. 

 

I am using If(equals(triggerBody()?['Term_Sheet_Needs_to_be_Generated__c'],bool('True')),'Need term sheet',If(equals(triggerBody()?['Milestones__c'], bool('True')),'Milestones need to be approved',If(equeals(triggerBody()?['Term_Sheet_Generated__c'],bool('True')),'Waiting on App Submission',If(equals(triggerBody()?['Info_Ready_to_be_Reviewed__c'],bool('True')),'Documents Need to Generated',If(equals(triggerBody()?['Docs_Created__c'],bool('True')),'Out for Signing',If(equals(triggerBody()?['Legal_Agreement_Process_Done__c'],bool('True')),'Completed','Waiting for Materials')))))

 

I have checked that all the fields are correct. 

 

If Logic 1.JPGIf logic 2.JPG

Dual Super User
Dual Super User

Re: If Logic in a Flow

@chartergrowth

There is a typo in one of the subexpressions

If(equeals(triggerBody()?['Term_Sheet_Generated__c']...

If this is not the problem I would recommend to start with a simple expression (one IF), save, and add the rest of the IFs one by one. I know it takes a lot of time to do it this way, but sometimes when an expression is so complex it is the only way to identify the problem.

Hope this helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





View solution in original post

nchambe
Level: Power Up

Re: If Logic in a Flow

Flow has now improved their condition control to allow more complex nested if/then statements and such using the visual builder. I wrote about it here: https://sharepointlibrarian.com/2019/02/05/flow-now-supports-multiple-condition-controls-for-advance...

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 (4,843)