15. Run a Backend Process
A UI process can start a business process on demand and read its answer. This is how you reach server-only work (email, secrets, CORS, a heavy query) from a button without duplicating that logic in the browser.
context.sdk.applications.runTrigger({ params, json })
async· returns{ success, result, error, triggerName, appSlug, executionTimeMs, executedAt }
Prop
Type
try {
const response = await context.sdk.applications.runTrigger({
params: { triggerId: "refreshtasks" },
json: { Location: context.event.Location }
});
if (!response.success) {
throw new Error(response.error || "Trigger failed");
}
context.toast.success("Tasks refreshed.");
} catch (error) {
console.error(error);
context.toast.error(error.message);
}The business process runs authenticated as the current app user. It sees that user on context.claims. The value the trigger returns is on response.result.
The previous frontend posted /Trigger?id=58. That numeric route is gone. Use the trigger file's basename, the same name you see in Process Designer.
When to use this
- Collapse an N+1 read into one server query
- Send email / SMS / a notification after a button click
- Call an external API that cannot run in the browser
- Reuse a business process that already exists, instead of rewriting it as UI code
After the trigger writes data, SDK auto-invalidation may not have run (the write happened on the server). Invalidate the entities the UI is showing:
await context.sdk.applications.runTrigger({
params: { triggerId: "generate-tasks" },
json: { ProjectId: context.router.id }
});
await context.sdk.invalidate.entities.getBySlug({ entitySlug: "tasks" });