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 of elements. For example, sending a notification to a group of users.
List of users
Batch 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
Scalar list input
Compound action for a scalar list
Scalar list result
Deduplicating a list of objects
In this case we will deduplicating a list of objects that have the same email key
Compound action for an object list
Sort alphabetically
Problem: You need to provide a list of elements sorted alphabetically
Alphabetical sort input arguments
Alphabetical sort compound action
Alphabetical sort result
Sort timestamps
Problem: You want to sort a list based on the timestamp
Sorting a list of timestamps
Timestamp list input
Timestamp sort compound action
Timestamp sort result
Sorting a list of objects by timestamp
Object list input
Object sort compound action
Object sort 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.
Create a page range helper action
First, create a helper action (e.g., a Script Action) that generates a range list for the for loop to iterate over:
Pagination compound action
How pagination 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 a multiline string’s structure to be maintained
Solution: Use Render() and the | character with your template value indented