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

IF statements with multiple conditions - How to fix?

Hi all,

I am creating a new Planner task for each new SharePoint item and post to Teams, and I have the following IF statements with multiple conditions when I tried to match the Bucket ID with Stage Names.

 

['Stage'] is a filed from the SharePoint list, and 'KEpnFzVXWEeJk1o..', 'EBmEdXXVs0mbdsPYV' are the corresponding Bucket IDs in Planner. Although the Expression doesn't have errors, the outputs are not what I expected. From the outputs, all newly created items were assigned to the last bucket "SLDSOP90EGLabXql".

 

Can anyone tell me what's wrong with the code? Thank you.

------------------------------------------------------------------------------------------

if(equals(triggerBody()?['Stage'],'Start'),'CSESXWEeJk1oNpP',
if(equals(triggerBody()?['Stage'],'Develop'),'JKSHDbdsPYV3Fh',
if(equals(triggerBody()?['Stage'],'Negotiation'),'XPSUDLKeL4cFk5C35j',
if(equals(triggerBody()?['Stage'],'Implementation'),'QKJSK9860dP2Lvp',
if(equals(triggerBody()?['Stage'],'Sign the contract'),'KSHDMX96kmU1G77h','SLDSOP90EGLabXql')))))

-------------------------------------------------------------------------------------------

My flow:

 
2 REPLIES 2
Highlighted
Super User II
Super User II

Re: IF statements with multiple conditions - How to fix?

Hi @New2Flow 

 

The screenshot wasn't uploaded but I have a recommendation for you. Instead of having nested IF statements why don't you use the Switch action and have each individual value in a case statement. Then you Flow would be a lot more debuggable since you would see the path of your data in the History and then check if there would be any issues. 

 

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

Cheers
Manuel

Highlighted
Dual Super User III
Dual Super User III

Re: IF statements with multiple conditions - How to fix?

Hi @New2Flow 

 

Can you try to update the expression as: 

if(equals(triggerBody()?['text'],'Start'),'CSESXWEeJk1oNpP',
if(equals(triggerBody()?['text'],'Develop'),'JKSHDbdsPYV3Fh',
if(equals(triggerBody()?['text'],'Negotiation'),'XPSUDLKeL4cFk5C35j',
if(equals(triggerBody()?['text'],'Implementation'),'QKJSK9860dP2Lvp',
if(equals(triggerBody()?['text'],'Sign the contract'),'KSHDMX96kmU1G77h','SLDSOP90EGLabXql')))))

Note that though you changed the input name to stage, it still reads as text internally and then if you create more input fields of type text, it will be internally read as text_1 and so on. 

 

Also, the switch control could be a good way in case there are not too many actions depending on the input value. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Users online (5,846)