How to Reduce a List to a Single Value (Using the Okta Workflows Reduce Card)

  1. Okta Workflow guides
  2. What is the Reduce card?
  3. Creating a list and calling the Reduce card
  4. Helper flow to process (reduce) each list item
  5. Additional guide resources
  6. What you learned
  7. Workflows resources

Okta Workflow guides

Okta Workflows guides are questions and answers from the community office hours, the #okta-workflows channel on MacAdmins Slack and other places. Read all the other how-to guides

How to reduce a list to a single value?

You have a list of values. You must combine them into a single value (a text or a sum) to include in an email or a Slack message. You can use the Reduce card to achieve that.

What is the Reduce card?

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

You have a list of text values:

  • Milk
  • Bread
  • Butter
  • Eggs
  • Cheese

You need a single text value consisting of all the values from the list:

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

You need to reduce the list into 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:

Creates the list and calling the Reduce card
Creates 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 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, 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
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
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

Additional guide resources

Additional resources about how to use the Reduce card:

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

What you learned

This guide taught you how to use the Okta Workflows Reduce card to reduce a list to a single value.


Workflows resources

🍫 Get help from Workflows specialists during weekly community office hours.

πŸ“Ί Learn from Workflows videos.

πŸ›Ÿ Get help from support: discuss a Workflows topic or ask a question.

πŸ™‹πŸ»β€β™€οΈ Join the #okta-workflows channel on MacAdmins Slack to learn and get help from the community.

Leave a comment