Common DSL & Mapper Patterns
Common DSL & Mapper Patterns
Common DSL & Mapper Patterns
Practical recipes for DSL and Data Mapper patterns that come up constantly in real builds. Each pattern includes a use case and a working example you can adapt.
For the full function references, see the DSL Reference and the Data Mapper Reference.
Before diving into patterns, you need to understand how constants work in compound action YAML. This is the single most confusing syntax element for new builders.
In compound actions and data mappers, bare values are treated as data bank references, not strings. If you write:
The system looks for data.approved in the data bank — it does NOT pass the string "approved". To pass a literal constant, you need quotes.
This is standard YAML quoting interacting with DSL evaluation:
'...') tell YAML to treat the content as a literal string (no YAML processing)'...') are the DSL string delimiter'''approved''' is YAML for: the DSL expression 'approved', which evaluates to the string constant approvedWhen referencing the data bank — that’s the default behavior:
APIs often reject requests with null fields. Use EVAL() with $FILTER to build an object and strip out any keys that are null or empty before sending.
Use case: Building a calendar event payload where recurrence and location are optional.
If location and recurrence are null, they disappear from the payload entirely.
Use MAP() to reshape each item in an array — rename fields, flatten nested values, or add computed fields.
Use case: Rename API field names to user-friendly names for SDA.
Use CONDITIONAL() to include a field only when a condition is met — useful for building dynamic query filters.
Use case: Only add a date filter to a SOQL query when the user provided a date.
Use MERGE() to combine objects from different action outputs into a single result — useful for compound actions that fetch from multiple sources.
Use case: Combine user data from one action with company data from another.
Use LOOKUP() when an API returns status codes or category IDs that need to be translated for the user.
Use case: Convert ServiceNow incident state numbers to labels.
Use RENDER() or $CONCAT to construct URLs from dynamic data — for linking back to source records.
Use case: Generate a clickable link to a ServiceNow ticket.
Use SORT() to order an array by a field.
Add reverse: 'true' for descending order.
Use in a slot validation policy to reject past dates.
Check that a date is at least 7 days from now (e.g., for travel booking lead time).
Use in for allowlist/blocklist validation.
Or with $ANY for more complex matching:
Chain string functions for normalization:
Build a full name from parts:
When passing structured data to mw.generate_text_action (which only accepts string input), use $STRINGIFY_JSON:
Use comparison operators in switch conditions:
These patterns use both DSL expressions inside Data Mappers.
Use RENDER() (mapper) with DSL expressions in the args:
Use DSL $FILTER inside a mapper MAP():