Use this file to discover all available pages before exploring further.
A SCRIPT step runs JavaScript inside an Activity. It is the right tool when the workflow needs custom logic that is too specific for a declarative step.Script steps are commonly used to inspect documents, normalize extracted data, assign knowledge features, call Service Bridges, and decide which branch of the Activity Plan should run next.
Route the Activity based on document content, metadata, extraction results, or task status
Make several checks before deciding whether human review is needed
Update document metadata, labels, tags, data objects, or attributes
Assign knowledge features to document families
Call one or more Service Bridges and combine their responses
Emit a named action for downstream dependencies
Do not use a script just to make one external API call. Use a Service Bridge step for that so the external call has its own step status, logs, retry behavior, and result.
A SCRIPT step can request another Activity Plan to start automatically when the current Activity completes. Use this to chain related work, e.g. “after intake classifies an invoice, kick off the extraction plan.”The spawned Activity:
Starts only after the current Activity reaches COMPLETED (not on individual step completion).
Inherits the current Activity’s project. The target plan must already be bound to that project.
Inherits the current Activity’s document families when documentFamilyIds is omitted.
Records its source in triggerMetadata (sourceActivityId, sourceStepId, sourceActionUuid, sourceProjectId) so audit trails work in both directions.
Spawn failures are soft. If the target plan doesn’t exist, FGAC denies, or inputs fail validation, the source Activity still finishes cleanly. The failure is recorded on the source step in script_result.nextActivityError. On success, script_result.nextActivityId is set to the new Activity’s ID.
Each SCRIPT step in a plan may emit its own nextActivity. They fan out at the source Activity’s completion in step insertion order. Within a single script return, only one nextActivity is supported.
A script can only spawn Activity Plans bound to the current project. Cross-project spawns are rejected. If you need fan-out across projects, model it through a Service Bridge call instead.
Activity Plan SCRIPT steps run in the server-side JavaScript runtime. The runtime exposes the same business objects the Activity is working on, plus helper namespaces for task state, document families, document content, Service Bridges, LLM calls, and knowledge features.
Object
Use
task
Snapshot of the Task that started the Activity, when the Activity is task-backed
families
Snapshot array of document families attached to the Task
org
Current organization { id, slug }
tasks
Query and mutate task records in the current project
documents
Query and mutate document family records in the current project
loadDocument(familyId) / documents.load(familyId)
Load a KDDB document for content nodes, tags, data objects, metadata, labels, validations, and exceptions
lookupFeature*
Find or create knowledge features for classification and routing
serviceBridge
Call project-scoped Service Bridges from custom decision logic
llm
Invoke configured LLM services with platform cost tracking
log / console
Write script logs visible from the Activity step details
The current Activity Plan script context is centered on the Task and its document families. Use prior step outputs through declarative step mappings, then pass the needed values into document metadata, task data, or downstream step configuration instead of assuming a generic inputs object exists in the script runtime.
Document changes are saved after the script completes. Modified KDDB documents are persisted as new content object versions with the SCRIPT_MODIFICATION transition type.
Sidecars are useful for shared validation functions, string cleanup, request mapping, and common routing decisions. Keep sidecars small and version them like any other project resource.