Workflows Tips #13: Six (Awesome) Tips for Using If/Else Logic
Tags: nocode, workflows, okta, ipaas
Published: 2022-08-23 21:40:45

---
title: Workflows Tips #13: Six (Awesome) Tips for Using If/Else Logic
published: true
date: 2022-08-23 05:00:18 UTC
tags: NoCode,Workflows,okta,ipaas
canonical_url: https://maxkatz.net/2022/03/25/workflows-tips-13-six-awesome-tips-for-using-if-else-logic/
---

{% embed https://dev.to/oktaworkflows/okta-workflows-tips-57bj %}


In this post:

- How to use OR in an if-statement
- Comparisons are type sensitive
- Don’t nest more than 3 If/Elseif statements
- Passing in values to be used within the If/Else
- Creating output for an If/Elseif card
- How to build a flow with multiple conditions

## How to use OR in an if-statement

_This tip is from [Arek Dreyer](https://www.linkedin.com/in/arekdreyer/). Arek is a Senior Product Engineer at [kandji.io](http://kandji.io/), which provides next-generation Apple device management for macOS, iOS, iPadOS, and tvOS. Arek spent over 20 years as an independent trainer, author, and consultant, and in 2021 he joined Kandji. He was super happy to discover the [community of admins](https://www.macadmins.org/) that love helping each other solve problems in the Okta Workflows space._

You need to create an if-statement for the following conditions:

```
If device has platform=Mac
If device has platform=iPhone or platform=iPad
If device has platform=Apple TV
```

Note that the second if-condition has two conditions. The achieve the `or` condition, use the **Branching – If/Elseif** card with **Else If** condition checking if the value is in a list.

[![Using Else If with OR condition](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_ifelse.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_ifelse.png)
<figcaption>Using Else If with OR condition</figcaption>

## Comparisons are type sensitive

_This tip is from [AJ Ahrens](https://www.linkedin.com/in/arthur-a-756209188/), Workflows Team Lead at Okta._

When using **Branching – If/Elseif** card, remember that comparisons are type sensitive. Check you are comparing the same data types. For example, **Number** comparison of numbers is different than **Text** comparison of numbers.

The **Flow Control – Assign** card has input as **Numbers**. But, in the **Branching – If/Else** card the compare types are set (by mistake) to **Text**.

[![If/Else card comparison with different data types](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_data_types1.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_data_types1.png)
<figcaption>If/Else card comparison with different data types</figcaption>

When you run the flow you get incorrect result due to incorrect data types:

[![Incorrect result due to incorrect data types](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_data_types2.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_data_types2.png)
<figcaption>Incorrect result due to incorrect data types</figcaption>

Go back to **If/Else** card and change the types to **Number** for the condition to be evaluated correctly.

## Don’t nest more than 3 If/Elseif statemets 

_This tip is from [AJ Ahrens](https://www.linkedin.com/in/arthur-a-756209188/), Workflows Team Lead at Okta._

Don’t nest more than 3 If/Elseif statements. It is difficult to understand how it works and debugging is even more challenging.

## Passing in values to be used within the If/Else

_This tip is from [AJ Ahrens](https://www.linkedin.com/in/arthur-a-756209188/), Workflows Team Lead at Okta._

This one is actually a tip-bug. It will be fixed. For now it’s a good idea to be aware of it and there is a workaround.

When you pass a value into an **If/Elseif** card as shown below you will get an error.

[![Passing values from outside If/Elseif](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_error1.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_error1.png)

[![Passing values from outside If/Elseif](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_error2.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_error2.png)
<figcaption>Passing values from outside If/Elseif</figcaption>

A solution until this bug is fixed is to use **Flow Control – Assign** card inside the **If/Elseif** card to pass in the value as shown below:

[![Passing values from outside If/Elseif with the help of Assign card](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_works2.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_works2.png)

[![Passing values from outside If/Elseif with the help of Assign card](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_works1.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_scope_works1.png)
<figcaption>Passing values from outside If/Elseif with the help of Assign card</figcaption>

## Creating output for an If/Elseif card

_This tip is from [Bryan Barrows](https://www.linkedin.com/in/bbarrows89/), Workflows Builder Advocate at Okta._

It might not be clear how to create an output for the **Branching – If/Elseif** card. Check out this 30-second video on how to create an output:

{% youtube nP6olKdPW7Q %}

## How to build a flow with multiple conditions

_This tip is from [Bryan Barrows](https://www.linkedin.com/in/bbarrows89/), Workflows Builder Advocate at Okta._

Ok, so this is how it works:

- Use multiple **True/False – Compare** cards for comparisons
- Take the restyle from these comparisons and feed them into **True/False – And** card. You can also use **[Or](https://help.okta.com/wf/en-us/Content/Topics/Workflows/function-reference/True-False/truefalse_or.htm)**, **[Or (Exclusive)](https://help.okta.com/wf/en-us/Content/Topics/Workflows/function-reference/True-False/truefalse_xor.htm)**, **[NOT](https://help.okta.com/wf/en-us/Content/Topics/Workflows/function-reference/True-False/truefalse_not.htm)**, and **[XNOR](https://help.okta.com/wf/en-us/Content/Topics/Workflows/function-reference/True-False/truefalse_xnor.htm)** cards
- From there, feed the true/false value to a **Branching – If/Else card** 

This allows to setup logic for different scenarios where you have a number of conditions and you either need all of them to be true, one of them to be true, none of them, etc.

[![Multi-condition flow](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_branch_and_2.png?w=1024)](https://katzmax.files.wordpress.com/2022/03/workflows_tips13_branch_and_2.png)
<figcaption>Multi-condition flow</figcaption>

* * *

Two resources to help you learn more:

📌 Try this step-by-step getting started tutorial: [Build Your First Automation With Okta Workflows: Notify When User Is Suspended](https://dev.to/maxkatz/build-your-first-automation-with-okta-workflows-notify-when-user-is-suspended-1l3p-temp-slug-2933517).

📌 All the [Workflows resources](https://dev.to/maxkatz/okta-workflows-resources-1ebi) (docs, tutorial, office hours, templates, office hours and more)