Skip to main content

Start with a contract, then a caller

These examples use only their input and return JSON-compatible dictionaries. Run them through the matching extension point in a test environment after saving and publishing. Creating a script does not connect it to a caller.

Normalize a Caseflow reference

Choose Caseflow Autofill (caseflow_autofill). The caller supplies trigger_value; the result maps target attribute names to string values.
Bind the published script to the intended Caseflow autofill target, and include CustomerReference among its allowed target attributes. Verify it in the consuming form. Decide separately whether an empty reference is acceptable; normalization does not enforce a required field.

Return a workflow decision

Choose Workflow Action (workflow_action). Configure a Script.Run action to supply the input key amount and capture its output into an instance variable.
Test amounts 9999 and 10000: the results are false and true respectively. Test a missing value, a string, a boolean, and a negative amount as rejected inputs. If your source keyword is text, convert it deliberately before passing it as a number. Use the returned decision in a subsequent workflow condition. The script does not create a task or update a document by returning this value; those are separate configured actions. Script.Run resolves the published script by slug, so publishing a workflow does not freeze the script version.

Acknowledge a document event

Choose Event Hook (event_hook). This minimal example verifies the event contract without writing to another system:
For event_type equal to document.created and entity_id equal to 1042, the message is Received document.created for entity 1042. Publish it, then create a binding for one test document type and the Document Created event. Create a representative document and inspect the script’s execution log. An acknowledgement is not an upload, callback, or business-state change.

Before adding an external integration

Replace the example behavior only after the caller, input, published version, and logs are working. Use context["api"] or context["http"] for the supported managed clients and context["secrets"] for configured credentials. Define what happens after a timeout or duplicate event before adding a write operation. Keep an external operation idempotent where possible, and distinguish “request accepted” from “business operation completed.” Script-authoring access is trusted access because executed scripts can read the secrets supplied to their scope.

Bindings and event hooks

Attach published scripts to external autofill sets, Caseflow forms, workflows, and document events.