githubEdit

Context Variables

Every script automatically receives the following variables in its execution context. These do not need to be imported — they are simply available.


Main Variables

document_data (alias: doc)

The root object containing all document data:

document_data = {
    "document_json": { ... },   # The document itself
    "fields": [ ... ],          # Array of all fields
    "fields_dict": { ... },     # Fields indexed by name
    "tables": [ ... ],          # Array of all tables
    "tables_dict": { ... },     # Tables indexed by name
}
circle-info

doc is an alias — doc and document_data point to the same object. Both can be used interchangeably.

document_json

Direct access to document_data["document_json"]. Contains:

document_json = {
    "doc_id": "uuid-...",
    "org_id": "uuid-...",
    "sub_org_id": "uuid-..." or None,
    "doc_type": "INVOICE",
    "sub_doc_type": None,
    "status": "ready_for_validation",
    "date_format_pattern": "%d.%m.%Y",      # For date formatting
    "amount_format_locale": "de_DE",         # For amount formatting
    "fields": [ ... ],                        # Field array
    "tables": [ ... ],                        # Table array
    "po_items": [ ... ],                      # PO matching results
    "po_match_status": "matched" | None,
    "already_verified_po_numbers": [ ... ],
}

fields and fields_dict

triangle-exclamation

tables and tables_dict

user_id, org_id, user

circle-exclamation

Common Access Patterns

Read and write fields

Iterate tables

Fulltext search in document

Sub-org routing

Last updated

Was this helpful?