Okta Workflows How-To: Create a Custom List Filter
Okta Workflows is a no-code platform for automating identity processes.
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 begin 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 the List – Filter card. Something like this:
Filtering a list with List – Filter card
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 that results in an empty list.
The solution is to use the List – Custom Filter card.
The List – Customer Filter card uses a helper flow to determine if a list item should or shouldn’t be included in the new (filtered) list.
Looking at the helper flow first, this is how it looks:
A helper flow to check if a list item matches a custom filter
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):
- Group name – actual group name such as No-code Builders
- Filter – text to look 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.
The main flow calling the helper flow:
Filter Custom card calling a helper flow
When you specify the helper flow, the 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
Filter is set to a text you are filtering.
After running this flow, the List – Custom Filter will return a list containing only groups with the filter text No-code.
To end the guide, this is how inputs from the main flow are related to 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
Watch a vidoe about how to create a custom filter.
Get your Workflows questions answered
Do you have a question about Okta Workflows? Not sure how to build a flow? Join the weekly community office hours to get help.