Skip to content

Commit 41704dd

Browse files
Copilothotlong
andcommitted
Update action.mdx: mark execute as deprecated, add target binding docs, platform comparison, and cross-reference validation section
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent ef45c5f commit 41704dd

1 file changed

Lines changed: 69 additions & 2 deletions

File tree

content/docs/references/ui/action.mdx

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const result = Action.parse(data);
3737
| **locations** | `Enum<'list_toolbar' \| 'list_item' \| 'record_header' \| 'record_more' \| 'record_related' \| 'global_nav'>[]` | optional | Locations where this action is visible |
3838
| **component** | `Enum<'action:button' \| 'action:icon' \| 'action:menu' \| 'action:group'>` | optional | Visual component override |
3939
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api'>` || Action functionality type |
40-
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint |
41-
| **execute** | `string` | optional | Legacy execution logic |
40+
| **target** | `string` | conditional | URL, Script Name, Flow ID, Modal/Page Name, or API Endpoint. **Required** for `url`, `flow`, `modal`, and `api` types; recommended for `script`. |
41+
| **execute** | `string` | optional | ⚠️ **Deprecated** — Use `target` instead. Auto-migrated to `target` during parsing. Will be removed in a future version. |
4242
| **params** | `Object[]` | optional | Input parameters required from user |
4343
| **variant** | `Enum<'primary' \| 'secondary' \| 'danger' \| 'ghost' \| 'link'>` | optional | Button visual variant for styling (primary = highlighted, danger = destructive, ghost = transparent) |
4444
| **confirmText** | `string \| Object` | optional | Confirmation message before execution |
@@ -51,6 +51,51 @@ const result = Action.parse(data);
5151
| **timeout** | `number` | optional | Maximum execution time in milliseconds for the action |
5252
| **aria** | `Object` | optional | ARIA accessibility attributes |
5353

54+
### Target Binding Rules
55+
56+
The `target` field is the canonical way to bind an action to its handler:
57+
58+
| Action Type | target | Description |
59+
| :--- | :--- | :--- |
60+
| `script` | Recommended | Function name to invoke (e.g. `completeTask`) |
61+
| `url` | **Required** | URL to navigate to |
62+
| `flow` | **Required** | Flow name to invoke (validated against defined flows) |
63+
| `modal` | **Required** | Page/modal name to open (validated against defined pages) |
64+
| `api` | **Required** | API endpoint to call |
65+
66+
### Examples
67+
68+
```typescript
69+
// Script action with handler target
70+
const action: Action = {
71+
name: 'complete_task',
72+
label: 'Mark Complete',
73+
type: 'script',
74+
target: 'completeTask', // ← references a registered handler function
75+
locations: ['record_header'],
76+
refreshAfter: true,
77+
};
78+
79+
// Flow action
80+
const flowAction: Action = {
81+
name: 'convert_lead',
82+
label: 'Convert Lead',
83+
type: 'flow',
84+
target: 'lead_conversion', // ← must match a defined flow name
85+
};
86+
87+
// Modal action
88+
const modalAction: Action = {
89+
name: 'defer_task',
90+
label: 'Defer Task',
91+
type: 'modal',
92+
target: 'defer_task_modal', // ← must match a defined page name
93+
};
94+
```
95+
96+
<Callout type="warn">
97+
**Migration Note:** The `execute` field is deprecated. If `execute` is provided without `target`, it is automatically migrated to `target` during schema parsing. Always use `target` in new code.
98+
</Callout>
5499

55100
---
56101

@@ -69,3 +114,25 @@ const result = Action.parse(data);
69114

70115
---
71116

117+
## Cross-Reference Validation
118+
119+
`defineStack()` validates action cross-references at build time:
120+
121+
- **`type: 'flow'`**`target` is checked against the `flows[]` collection (when flows are defined).
122+
- **`type: 'modal'`**`target` is checked against the `pages[]` collection (when pages are defined).
123+
124+
When the target collection is empty, validation is skipped because referenced items may come from plugins.
125+
126+
---
127+
128+
## Platform Comparison
129+
130+
| Capability | ObjectStack | Salesforce | ServiceNow | Power Platform |
131+
| :--- | :--- | :--- | :--- | :--- |
132+
| **Declarative actions** | `ActionSchema` with `target` binding | Lightning Actions (Quick Actions) | UI Actions / Client Scripts | Power Fx `OnSelect` |
133+
| **Action types** | `script`, `url`, `modal`, `flow`, `api` | URL, Flow, LWC, Visualforce | Client Script, UI Policy, Flow | Navigate, Patch, Launch |
134+
| **Handler binding** | `target` string → `engine.registerAction()` | Apex Controller `@AuraEnabled` | Script Include + GlideAjax | Power Automate Cloud Flow |
135+
| **Cross-ref validation** | Build-time (`defineStack`) | Deploy-time (Metadata API) | Update Set validation | Solution Checker |
136+
| **Modal integration** | `type: 'modal'` + page name target | `lightning:overlayLibrary` | GlideModal / GlideDialogWindow | `Navigate(Screen)` |
137+
| **Bulk operations** | `bulkEnabled` + `locations: ['list_toolbar']` | List Button + Mass Quick Action | List v3 Actions | Gallery `OnSelect` multi |
138+

0 commit comments

Comments
 (0)