October 31, 2024

Sometimes one function is not enough, so combining multiple is necessary. To help us with that, we have the “or” function. It combines multiple functions that return a boolean value and return “true” if at least one of them returns “true”. Only if all of the returns “false” will it return “false”.

Simple enough, but let’s explore it.

Usage

It follows a simple pattern.

  1. Expression 1
  2. ….

You can have more than two, but you need to have at least two expressions.

Example:

or(true,true)

will return 

true

How about if we include a “false”?

or(true,true,true,true,false)

will return 

true

We would only get a false here if all of them were false.

Let’s look at more practical examples. Let’s think about a variable that contains the age, and we want to check if the age is 18 or 19 for some reason. We can use the “if” function, the equals function, to get the result. Our “or” function brings all of them together.

if(or(equals(variables('AGE'), 18) ,equals(variables('AGE'), 19)), 'We have our age validated', 'out of range')

value for the variable variables('TEST_INT') is 17

will return 

"out of range"

value for the variable variables('TEST_INT') is 18

"We have our age validated"

Notice that when we can build the function by thinking of what we need:

I want to check IF a VARIABLE has an age that is EQUALS to 18 OR EQUALS to 19

You could even do it without the “if” function.

or(equals(variables('AGE'), 18), equals(variables('AGE'), 19))

will return

true

Ensure that the functions or variables always return a boolean; otherwise, Power Automate will error. For example:

or(true,'test')

will return an error

Here’s the error:

Unable to process template language expressions in action 'Compose' inputs at line '1' and column '4722': 'The template language function 'or' expects all of its parameters to be booleans. Found invalid parameter types: 'String'.'.

The error message is relatively straightforward, so it’s easier to find the offending parameter.

Limitations

I don’t know about a documented limitation, but I want to know about it if you have a good example. Please email me or interact on Twitter.

Recommendations:

Here are some things to keep in mind.

Divide to conquer

It’s possible to nest “or” functions, and it may make sense. For example, you can have “and” functions that can control parts of the conditions.

I only warn caution because expressions can become significant and unmanageable quickly. Also, it’s hard to debug, so I would recommend having separate conditions in logical “blocks” if you can, of course. Debugging is a lot easier in this case.

Sources:

Microsoft’s join Function Reference

Back to the Power Automate Function Reference.

Photo by Paul Pascale on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon