Skip to main content

Notifications

Power Automate - Building Flows
Answered

Troubleshooting nested or(if,if,if,if) expression

Posted on by 80
I have the following or(if) expression:
 
or(
if(contains(outputs('Compose'), 'ANS'), 'e8...bd', ''),
if(contains(outputs('Compose'), 'SOL'), '9a...24', ''),
if(contains(outputs('Compose'), 'RD'), '4d...85', ''),
if(contains(outputs('Compose'), 'LD'), '60...14', ''),
if(contains(outputs('Compose'), 'Internt'), '99...fd', '')
)
 
Any of the single statments work without a problem, but if I wrap them in an or function with commas between, they fail with the following message: 

Unable to process template language expressions in action 'Post_studio_meeting' inputs at line '0' and column '0': 'The template language function 'or' expects all of its parameters to be booleans. Found invalid parameter types: 'String'.'.
 
I don't see any busted '' and the documentation on the Or function isn't helpful. Any advice?
 
 
  • Verified answer
    AndreasO Profile Picture
    AndreasO 80 on at
    Troubleshooting nested or(if,if,if,if) expression
    Figured it out. Using OR was improper here since the IF conditions return values instead of true/false. Nesting the IF conditions instead worked. 
     
    if(contains(outputs('Compose'), 'ANS'), 'e8...bd', 
       if(contains(outputs('Compose'), 'SOL'), '9a...c24', 
          if(contains(outputs('Compose'), 'RD'), '4d...85', 
             if(contains(outputs('Compose'), 'LD'), '60...14', 
                if(contains(outputs('Compose'), 'Internt'), '99...fd', '')
             )
          )
       )
    )
     If anyone reading this is trying to figure out the logic here, look at the lack of a second , in the first IF statement. The syntax for an if statement is "if(logical test), result if true, result if false". In the above code, the next IF statement runs if the first logic test returns false. This can cascade indefinitely, but if you know one option is more likely than another, that should optimally be put first or early in the chain of If statements. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard