cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
chartergrowth
Frequent Visitor

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

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

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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

9 REPLIES 9
efialttes
Super User III
Super User III

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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



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!

@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 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



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

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!

 

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.

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

@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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

nchambe
Regular Visitor

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (85,176)