Starting a process
Add process start buttons to a List so people can start work while browsing related records. From the Web orders List, Sales can enter a new order or request cancellation of an existing one.
This simplified example defines both processes and connects them to the List. It uses sample rows; submitting either form captures the details in a process execution but does not add or cancel an order in the List.
import { NumberField, TextField } from "@pf/form-schema"import { Form, List, Organisation, Process, Role } from "@pf/process"import { Effect, Schema } from "effect"
export const org = new Organisation({ name: "Demo Store" })const sales = new Role(org, "Sales")
const webOrder = new Process(org, "web-order", { name: "Enter web order", purpose: "Capture a new web order",})const captureOrder = new Form(webOrder, "Capture order", { role: sales, form: Schema.Struct({ sku: TextField({ label: "SKU" }), quantity: NumberField({ label: "Quantity" }), }),})webOrder.start(captureOrder).end()
const cancelOrder = new Process(org, "cancel-web-order", { name: "Request cancellation", purpose: "Record a request to cancel a web order",})const requestCancellation = new Form(cancelOrder, "Request cancellation", { role: sales, form: Schema.Struct({ orderId: TextField({ label: "Order ID" }), reason: TextField({ label: "Reason for cancellation" }), }),})cancelOrder.start(requestCancellation).end()
const orders = [{ id: "ORD-101", sku: "ABC-123", quantity: 2 }]
new List(org, "web-orders", { name: "Web orders", purpose: "Browse submitted web orders", roles: [sales], output: { id: Schema.String.annotate({ title: "Order ID" }), sku: Schema.String.annotate({ title: "SKU" }), quantity: Schema.Number.annotate({ title: "Quantity" }), }, query: ({ page, limit }) => { const offset = (page - 1) * limit return Effect.succeed({ items: orders.slice(offset, offset + limit), totalCount: orders.length, }) }, startProcess: webOrder, additionalStartProcesses: [cancelOrder],})startProcess specifies the primary action. Use
additionalStartProcesses for other actions. Each button opens the
corresponding process’s start form and is only shown to users who can
start that process. Viewing the List does not grant start permission.
Unlike Create record, submitting a start form starts a process execution. In a live project, later steps could save the new order or route the cancellation request for approval.