<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
How to Reduce a List to a Single Value Using the Workflows Reduce Card
Workflows
Okta Classic Engine
Okta Identity Engine
Overview

This guide presents how to reduce a list to a single value using the Workflows Reduce card. 

Applies To
  • Okta Workflows
Solution

What is the Reduce card?

The Reduce card takes a list of values and reduces them to a single value.


For example, there is a list of text values:

  • Milk
  • Bread
  • Butter
  • Eggs
  • Cheese

It is desired to obtain a single text value consisting of all the values from the list:

> Groceries: 
* Milk
* Bread
* Butter
* Eggs
* Cheese

It is necessary to reduce the list to a single value.
 

The solution has two flows:

  1. The main flow that creates the list and calls the Reduce card
  2. A helper flow that concatenates each text

 

Creating a list and calling the Reduce card

The main flow creates the list and calls the Reduce card:

Assembling the list and calling the Reduce card 

  1. The List – Construct card creates the list.
  2. The List – Reduce card takes the list and runs the Helper helper flow on each item.
    • memo has an initial value of > Groceries.
    • Values from the list will be added to the initial value.
    • Item is each item value from the list
    • In the output section, the item holds the reduced value after all the items are processed.
  3. The Text – Compose card displays the reduced value.

NOTE: memo field type (Text) needs to match the card’s output item field type (Text).


Helper flow to process (reduce) each list item

This is the helper flow:

Helper flow to process (reduce) each item


The helper flow runs for each item in the list.


First run

On the first run, the memo value is:

> Groceries

and

* Milk

is appended to it.

The helper flow returns:

> Groceries
* Milk

 


Second run
On the second run, the memo value is:

> Groceries
* Milk

and

* Bread

is appended to it.

The helper flow returns

> Groceries
* Milk
* Break

 


Third run
On the third run, the memo value is:

> Groceries
* Milk
* Break

and

* Butter

is appended to it.

The helper flow returns:

> Groceries
* Milk
* Break
* Butter

 


Fourth run
 On the fourth run, the memo value is:

> Groceries
* Milk
* Break
* Butter

and

* Eggs

is appended to it.

The helper flow returns:

> Groceries
* Milk
* Break
* Butter
* Eggs

 


Fifth run
On the fifth run, the memo value is:

> Groceries
* Milk
* Break
* Butter
* Eggs

and

* Cheese

is appended to it.

The helper flow returns:

> Groceries
* Milk
* Break
* Butter
* Eggs
* Cheese

Since cheese is the last item, the Reduce card completes processing.


The last helper flow run:

Flow execution history


This is the final result. A list of items is reduced to a single text value

> Groceries
* Milk
* Break
* Butter
* Eggs
* Cheese

 

Related References

  • Learn the Differences Between Three Workflows List Functions: For Each, Map, and Reduce (guidevideo).
  • How to Reduce a List to a Single Value, 3 Examples Using List-Reduce Workflows Card (guidevideo).
Loading
How to Reduce a List to a Single Value Using the Workflows Reduce Card