Runtime Characteristics
GoJA supports ES5 with partial ES6 features including arrow functions, template literals,
let/const, and destructuring. However, it is synchronous only — there is no support for async/await, Promises, or event loops.- Sandboxed — no filesystem access, no network access (except via service bridges)
- No module system — no
require()orimport - Synchronous — all calls are blocking; no callbacks or timers
- Deterministic — same inputs always produce same outputs
Execution Contexts
Scripts run in different contexts depending on where they are configured. Each context has its own timeout, globals, and intended purpose.Core Globals
These functions are available in all scripting contexts.log
Write messages to the platform execution log via leveled methods. Each method is variadic and joins arguments with spaces.log.debug, log.info, log.warn, log.error.
console.log()
A convenience wrapper that joins arguments with a space and writes at debug level.Document API — ScriptDocument
TheScriptDocument object represents a loaded Kodexa document (KDDB). It is available as document in intake scripts and returned by loadDocument() in script steps.
- Identity and Metadata
- Content Nodes
- Data Objects
- Mutations
Example: Querying a Document
Data Object API — ScriptDataObject
Data objects represent extracted entities (invoices, line items, claims) within a document. They form a tree structure with parent-child relationships.- Read Attributes
- Write
getFirstAttributeValue() returns the current typed value, not the original extracted text. The value precedence is: stringValue > decimalValue > booleanValue > dateValue (RFC 3339) > raw value.Example: Reading and Writing Attributes
Data Attribute API — ScriptDataAttribute
Data attributes store individual typed values on a data object. Each attribute has a tag name, optional typed values, and audit trail tracking.- Read
- Write
Type resolution. Both
setAttribute and addAttribute resolve the new attribute’s TypeAtCreation in the same precedence order:opts.type(advanced override onaddAttribute)- A runtime-supplied
TaxonResolver(browser subscriptions wire one) - The document’s cached taxonomies — taxonomies travel with the document via the KDDB
- A fallback inferred from whichever typed-value field the caller supplied (e.g.
decimalValue→DECIMAL,stringValue→STRING)
document.addTaxonomy(taxonomy) — the next write call sees the new taxonomy.Numeric taxon types — NUMBER, INTEGER, DECIMAL, CURRENCY, and PERCENTAGE — all share the underlying DecimalValue slot and are routed there automatically. Don’t pass type: "DECIMAL" on numeric writes; the resolver picks the right slot from the taxon.Example: Updating an Attribute
Content Node API — ScriptContentNode
Content nodes represent the structural elements of a document’s content tree: pages, lines, words, tables, and cells.- Selectors
- Spatial
- Mutations
Example: Searching Content Nodes
Context-Specific Details
Intake Scripts
Intake scripts run when a file is uploaded to a document store. Use them to validate, classify, or route incoming files.Script Steps
Script steps run inside Activity Plans and can load documents, call service bridges, invoke LLMs, and read the knowledge resolved on the in-scope family.Event Subscriptions
Event subscriptions run in response to attribute changes on data objects within a taxonomy. They are configured on the Event Subscriptions tab of the taxonomy editor.Selection Option Formulas
Selection option formulas compute dynamic dropdown values for data form fields. They can call service bridges and reference attributes.Best Practices
Debugging tip: Use
log.debug(...) liberally during development. Debug-level messages appear in the execution log but do not affect production behavior. Remove or reduce logging once the script is stable.Common Patterns
Null-safe Attribute Access
Iterating Children
Conditional Attribute Creation
setAttribute is idempotent — it finds-or-creates the attribute. There is no need to check whether it already exists.
