Update workflows documentation (#22356)

## Summary

Documentation-only updates to the workflow and logic-function docs:

- **Code action ↔ logic functions**: clarify that each Code action is
backed by its own logic function, and document how to reuse logic across
workflows via `workflowActionTriggerSettings` (Code/User Guide + Logic
Functions/Developer docs cross-linked).
- **`workflowActionTriggerSettings` example**: add a complete example
(`label`, `icon`, `inputSchema`, `outputSchema`) and document the
previously-undocumented `outputSchema` field.
- **Iterator improvements** (docs for #22031): document the new **"Use
the whole item"** (reference the whole current item) and **"Whole
list"** (loop over a step's top-level array output) options across the
Iterator and array-handling guides.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/22356?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
Marie
2026-06-30 14:58:18 +02:00
committed by GitHub
parent 3031891491
commit 46ef8a8813
4 changed files with 109 additions and 5 deletions
@@ -23,6 +23,12 @@ Iterator expects an **array** as input. It then:
3. Moves to the next item
4. Repeats until all items are processed
### Selecting the array to loop over
Most array sources (Search Records, a webhook array field, a Bulk manual trigger) can be selected directly in the variable picker.
When a **Code** or **Logic Function** step returns a *top-level array*, its output appears in the variable picker as indexed entries (`0`, `1`, `2`, …). To loop over the array as a whole, select the **Whole list** option for that step — the Iterator then infers the shape of each item from the list automatically.
## Basic Setup
### Example: Email Everyone in Search Results
@@ -76,6 +82,8 @@ Inside Iterator, use `{{iterator.currentItem}}` to access the current record:
| `{{iterator.currentItem.company.name}}` | Related company name |
| `{{iterator.index}}` | Current position in array (0-based) |
In the variable picker, you can either drill into a specific field of the current item, or pick **Use the whole item** to reference the entire current item (`{{iterator.currentItem}}`). Selecting the whole item is handy when you want to pass a full record straight into a downstream step rather than rebuilding it field by field.
## Common Patterns
### Update Multiple Records
@@ -93,14 +93,14 @@ Creates a new record or updates an existing one based on matching criteria. This
**Loops through an array of records** returned from a previous step, allowing you to perform actions on each record individually.
**Configuration**:
- Select the array of records from a previous step (e.g., results from Search Records, from a Manual trigger with Bulk availability, from a code node)
- Select the array of records from a previous step (e.g., results from Search Records, from a Manual trigger with Bulk availability, from a code node). When a Code or Logic Function step returns a top-level array, select its **Whole list** option to loop over the entire output.
- Define the actions to perform on each record in the loop.
<Note>
- You can add several actions within an iterator.
- When using branches inside an iterator, make sure the last step of each branch connects back to the iterator to close the loop.
</Note>
- Access `Current Item` Fields: to use fields from the record currently being processed, click on the **Iterator** step, then select **Current item**. The list of available fields from that record will be displayed and can be selected for use in subsequent actions.
- Access `Current Item` Fields: to use fields from the record currently being processed, click on the **Iterator** step, then select **Current item**. The list of available fields from that record will be displayed and can be selected for use in subsequent actions. You can also select **Use the whole item** to pass the entire current item into a downstream step.
<VimeoEmbed videoId="1146577247" title="Video demonstration" />
@@ -207,6 +207,8 @@ The fields cannot be made mandatory.
### Code
Runs custom JavaScript within your workflow.
Behind the scenes, each Code action is backed by its own **logic function** — a server-side TypeScript function that runs on the Twenty platform. When you add a Code action, Twenty creates a dedicated logic function for that step and exposes its editor inline, so the code you write lives with the workflow.
**Configuration**:
- Access variables from previous steps. You can edit the variables names dynamically.
<VimeoEmbed videoId="1147281795" title="Video demonstration" />
@@ -226,6 +228,25 @@ If you need to use external API keys in your code, you must input them directly
Click the square icon at the top right of the code editor to display it in full screen — helpful since the default editor width is limited.
</Tip>
#### Reusing a logic function across workflows
The inline Code action is great for one-off logic, but the code it holds belongs to that single step. When you want to share the same logic across several workflows — or maintain it as versioned source in an app — define a **reusable logic function** instead of copy-pasting code into each Code action.
A logic function is defined once in an app (using the SDK's `defineLogicFunction`) and exposed to the workflow builder by adding `workflowActionTriggerSettings`. Once your app is installed, that function appears as its own action in the workflow builder, alongside the built-in actions. Selecting it renders the input fields you declared (with variable pickers, just like other actions) and runs your shared code — no inline JavaScript required.
| | Code action | Reusable logic function |
|---|---|---|
| **Where the code lives** | Inline editor, tied to one workflow step | Defined in an app, versioned in source control |
| **Reuse** | Copy-pasted per step | Added as an action in any workflow |
| **Inputs** | Variables wired in the editor | Fields rendered from your declared input schema |
| **Best for** | Quick, workflow-specific logic | Shared logic used across multiple workflows |
Both run on the same logic function runtime, so a Code action you've prototyped inline can later be promoted into a reusable logic function with minimal changes.
<Tip>
For the developer-facing reference on defining logic functions and exposing them to the workflow builder, see [Logic Functions](/developers/extend/apps/logic/logic-functions) — in particular the **Exposing a function as an AI tool or workflow action** section and `workflowActionTriggerSettings`.
</Tip>
### HTTP Request
Sends a request to an external API as part of your workflow.
<img src="/images/user-guide/workflows/http_action.png" style={{width:'100%'}}/>