Compound Action Patterns
This document’s purpose is to accelerate your development process by providing a collection of reusable patterns for common tasks.
Instead of showcasing entire** end-to-end** use cases, this guide focuses on individual, common “steps” you’ll encounter while building. For each pattern, we recommend the most efficient method, whether it’s an LLM action, a Moveworks Data Mapper expression, a DSL query, or a Python Script.
Let’s dive into the patterns.
Performing Actions in Batch
Problem: You want to perform a series of actions repetitively for a list elements. For example, sending a notification to a group of users.
List of users
Usage Compound Action
Deduplicating a List
Problem: You have a list that contains duplicate values, and you need a list with only unique elements.
Deduplicating a list of scalars
Input
Usage in Compound Action
Result
Deduplicating a list of objects
In this case we will deduplicating a list of objects that have the same email key
Usage in Compound Action
Sort Alphabetically
Problem: You need to provide a list of elements sorted alphabetically
Input Arguments
Compound Action
Result
Sort Timestamps
Problem: You want to sort a list of based on the timestamp
Sorting a list of timestamps
input
Compound Action
Result
Sorting a list of objects by timestamp
Input
Compound Action
Result
Pagination with For Loops
Problem: You need to paginate through an API that returns results page-by-page using a pagination token (e.g., nextPageToken), but compound actions don’t support while loops.
Solution: Use a for loop with a fixed range (0 to MAX_PAGES), and on each iteration:
- Read the pagination token from the previous iteration’s output using
index - 1 - Use a
conditionto skip iterations once there are no more pages - Pass the token (or
nilfor the first page) into the HTTP action
Do not use parallel expressions with this pattern. Because each iteration reads from the previous iteration’s output in the data tree, the loop must execute sequentially.
Why not a while loop? Open-ended while loops are not supported in compound actions for safety reasons — a misconfigured loop could run indefinitely. The for-loop-with-condition pattern gives you the same pagination behavior with a guaranteed upper bound on iterations.
Setup
First, create a helper action (e.g., a Script Action) that generates a range list for the for loop to iterate over:
Compound Action
How It Works
Extracting All Results
After the loop completes, you can use a Script Action to flatten all pages into a single list:
Real-World Example: Polling an API Until Success
This same pattern works for polling use cases (e.g., waiting for an Okta push verification):
Easiest way to multiline string usage in YAML
Problem: You want to a multiline string’s structure to be maintained
Solution: Use Render() and the | character with your template value indented