How to Create a Custom List Filter in Okta Workflows
Tags: nocode, workflows, okta, ipaas
Published: 2022-08-30 18:34:42

---
title: How to Create a Custom List Filter in Okta Workflows
published: true
date: 2022-08-30 06:21:28 UTC
tags: NoCode,Workflows,okta, ipaas
canonical_url: https://maxkatz.net/2022/07/08/how-to-create-a-custom-list-filter-in-okta-workflows/
---

[Okta Workflows](https://www.okta.com/platform/workflows/) how-to guides are questions and answers from weekly community [office hours](https://calendly.com/oktaworkflows/group-office-hours-okta-workflows), MacAdmins [Workflows Slack channel](https://www.macadmins.org/), and other places. 

Read all the other how-to guides ⤵️
{% embed https://dev.to/oktaworkflows/all-okta-workflows-how-to-guides-4nl9 %}

On to the question. 

**_How to create a custom list filter_**?

Let’s say you want to get a list of all user groups in your organization that start with a particular text. For example you are looking for all groups that start with **No-code**.

This is not the right solution but I ran into this problem myself so I’m sharing it here. The first thing you will try is to use **List – Filter** card. Something like this:

[![Filtering a list with List – Filter card](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customfilter_standardfilter.png?w=1024)](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customfilter_standardfilter.png)
<figcaption>Filtering a list with List – Filter card</figcaption>

But, this will not work. Let’s use a group name of **No-code Builders** for this example.

You want to check if **No-code** is `in` **No-code Builders** group name. But instead, this card checks if **No-Code Builders** is `in` **No-code** which results in an empty list.

The solution is to use **List – Custom Filter** card.

**List – Customer Filter** uses a helper flow to determine if a list item should or shouldn’t not be included in the new (filtered) list.

Looking at the helper flow first, this is how it looks:

[![A flow (helper flow) to check if a list item matches a custom filter](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customsearch_helperflow.png?w=1024)](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customsearch_helperflow.png)
<figcaption>A flow (helper flow) to check if a list item matches a custom filter</figcaption>

The helper flow can contain any logic to determine if a current list time should or should not be included in a returned new list. If the helper flow returns a true – then the item will be added to a new list. If the flow returns false – then the time will not be added to the new list.

In this example, the main flow passes two variables to the helper flow ( **On Demand – Helper Flow** card):

1. **Group name** – that’s the actual group name such as **No-code Builders**
2. **Filter** – text you are looking for in a **Group name**

The second card ( **Text – Find** ) takes the **Filter** text and searches for it in the **Group name**. If it finds a match, it returns its **position** which will be 0 or greater. If no match is found, then it will return -1.

The next card, **True/False – Expression** checks to see if the value is less than 0 and then negates it.

If a match is found ( **position = 0** or **position > 0** )

- ( **position < 0** ) evaluates to **false** 
- **not** ( **position < 0** ) becomes **true**

If a match is not found ( **position = -1** )

- ( **position < 0** ) evaluates to **true** 
- **not** ( **position < 0** ) becomes **false**

The last card, **Flow Control – Return** returns **true** or **false**

- If the return value is **true** , then the item should be added to the list
- If the return value is **false** , then the item will not be added to the list. 

This is the main flow calling the helper flow:

[![Filter Custom card calling a helper flow](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customersearch_mainflow.png?w=826)](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customersearch_mainflow.png)
<figcaption>Filter Custom card calling a helper flow</figcaption>

When you specify the helper flow, **Group name** and **Filter** variables will be shown.

**Group name** is set to **Profile.Name** (click on the down arrow on the right of the field). **Profile.Name** is a path in a JSON group list.

[![Setting helper flow input](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customsearch_jsonpath.png?w=600)](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customsearch_jsonpath.png)
<figcaption>Setting helper flow input</figcaption>

**Filter** is set to a text you are filtering for.

After running this flow, **List – Custom Filter** will return a list that contains only groups that have the filter text **No-code** in them.

To end the guide, this is how inputs from the main flow are related with the helper flow. You first define inputs in the helper flow. When you set a helper flow in the main flow ( **Helper Flow** ) those inputs will be shown ( **Group name** and **Filter** ).

[![Helper flow inputs](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customsearch_main_and_helper.png?w=1024)](https://katzmax.files.wordpress.com/2022/07/workflows_howto_customsearch_main_and_helper.png)
<figcaption>Helper flow inputs<figcaption>

* * *

📺 Short how-to [Workflows videos](https://youtube.com/playlist?list=PLIid085fSVdvyK8F4xuk49EchBPmAVNHG) to help you become a better automation builder.

🔮 A collection of helpful [Workflows tips](https://maxkatz.net/okta-workflows-tips/).