> For the complete documentation index, see [llms.txt](https://developer.vario-software.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.vario-software.de/documentation/scripting/introduction.md).

# Introduction

Run server-side JavaScript inside the ERP — workflows and batch processing.

VARIO Cloud is a cloud ERP system with a built-in scripting engine for server-side business logic automation. Scripts are written in JavaScript and executed in a sandboxed GraalJS runtime on the VARIO backend — no external servers, no middleware, no deployment pipelines. They can read, validate, transform, and write ERP records the moment an event occurs, with full transactional safety and zero network latency.

Every business eventually outgrows the standard feature set. An ERP that cannot be extended becomes a bottleneck. VARIO Cloud Scripting removes that bottleneck: any rule, automation, or integration you can express in JavaScript becomes a native part of the system — invisible to end users, auditable through logs, and versioned alongside your workflows. The scripting engine runs on the same Java backend that powers the REST API, and the full service layer is available to every script.

***

## What You Can Do

With VARIO Cloud Scripting, you can automate any business process in the ERP:

* **Validate** — enforce business rules before data is persisted, blocking saves that violate your constraints
* **Enrich** — auto-fill fields, resolve references, and set defaults based on context when entities are created or modified
* **React** — trigger follow-up actions in response to entity lifecycle events — create tasks, update related records, notify stakeholders
* **Orchestrate** — pause execution to prompt users for decisions, then continue down the chosen path
* **Branch** — route logic based on entity type, state, or any field value, applying different rules to different scenarios
* **Transform** — convert documents between types, update statuses, and chain operations together automatically
* **Import** — process CSV or JSON files row by row to create or update entities in bulk, with full field mapping and error handling per row
* **Integrate** — call external REST APIs (newsletter tools, chat, AI models, marketplaces, suppliers) with credentials kept in encrypted secrets
* **Generate** — write CSV, XML or text files into the DMS, download files from URLs into the DMS, see [Files & Export](https://developer.vario-software.de/documentation/scripting/files-and-export.md)
* **Communicate** — print or e-mail documents, dunning letters and notifications through the regular output rules, see [Output](https://developer.vario-software.de/documentation/scripting/output.md)
* **Schedule** — run scripts on a cron schedule for nightly jobs or polling external systems

→ [Use Cases](https://developer.vario-software.de/documentation/scripting/use-cases.md) shows complete recipes, from newsletter sync to AI-generated product texts.

***

## Two Scripting Contexts

VARIO Cloud provides two scripting contexts. Both share the same service layer — every service available in a workflow is also available in a batch script. The difference is how scripts are triggered and what data they receive.

### Workflows

Event-driven scripts that react to entity lifecycle events — saving, creating, transferring, or editing records. A workflow consists of a trigger, one or more script elements, optional branching logic, and user interaction steps. Workflows are the primary mechanism for real-time automation.

→ [Workflow documentation](https://developer.vario-software.de/documentation/scripting/workflows.md)

### Batch Processing

Data import scripts that process files or list selections row by row. Each row passes through the callbacks `setGuard` and `setAction`, and `setAfterBatch` runs once at the end if at least one row succeeded — giving you full control over how external data maps into VARIO entities. Batch scripts are designed for bulk operations like importing articles, customers, or suppliers from external systems. Script processings can be scheduled to run automatically using Cron expressions, enabling fully unattended recurring data syncs.

→ [Batch Processing documentation](https://developer.vario-software.de/documentation/scripting/batch-processing.md)

***

## Shared Service Layer

Both scripting contexts in VARIO Cloud access ERP functionality through `ctx.services` — a rich set of services for reading, creating, updating, and querying entities, resolving references, managing users, and logging.

→ [Services documentation](https://developer.vario-software.de/documentation/scripting/services.md)

***

## Script Modules

Reusable JavaScript modules that can be imported by any workflow or batch script. Modules are managed centrally and can be organized into groups.

> [Script Modules documentation](https://developer.vario-software.de/documentation/scripting/script-modules.md)

***

## Further Script Hooks

Besides workflows and batch processing, scripts can run in these places:

| Hook             | Where                               | Purpose                                                                                      |
| ---------------- | ----------------------------------- | -------------------------------------------------------------------------------------------- |
| Output scripts   | Einstellungen → Allgemein → Ausgabe | Run before an output; change output type, format, quantity or language, or cancel the output |
| App scripts      | System → Apps → tab Skripte         | Adjust data exchanged with an app, for example the Shopware 6 or Shopify article export      |
| Picklist scripts | Picklist templates                  | Distribute picklist lines to pick boxes                                                      |

The entry modules for all hooks are listed in [Script Modules](https://developer.vario-software.de/documentation/scripting/script-modules.md#built-in-modules).

VARIO Local Link can also run a Node.js script on each file a watch folder picks up, before the upload to the DMS. These scripts run on the Local Link machine, not in the ERP; see [Local Link Transform Scripts](https://developer.vario-software.de/documentation/scripting/local-link-transform-scripts.md).

***

## HTTP & Secrets

Scripts can call external HTTP APIs. Targets must be allowed in the HTTP whitelist, and credentials are stored as encrypted secrets and referenced by placeholders.

→ [HTTP & Secrets documentation](https://developer.vario-software.de/documentation/scripting/http-and-secrets.md)

***

## Runtime & Limits

Scripts run in a sandboxed GraalJS context that is created fresh for every run.

| Aspect         | Behaviour                                                                                                                                                                              |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Language       | Modern JavaScript with ES modules (`import` / `export`)                                                                                                                                |
| Output         | No `console` or `print` — use `ctx.services.logger`                                                                                                                                    |
| Host access    | No Java classes, threads, native code or file system — only `ctx.services`                                                                                                             |
| Execution time | A run is stopped after 5 minutes of JavaScript execution; time spent inside service calls does not count                                                                               |
| Numbers        | Decimal values arrive as JavaScript numbers; very large IDs arrive as strings                                                                                                          |
| Network        | Only through `httpClientService`, only to whitelisted targets                                                                                                                          |
| Helpers        | JSON is built in; there is no crypto, hash or Base64 helper                                                                                                                            |
| Licence        | Writing and running your own scripts requires the scripting licence; unmodified VARIO presets run without it. Workflows and scheduled script processings require the workflow licence. |

***

## Getting Started

1. Open the **Workflows** section in VARIO Cloud
2. Create a new workflow and choose a trigger
3. Add a script element and write your first `setAction`
4. Use the built-in autocompletion to explore `ctx.availableInput` and `ctx.services`
5. Check the execution log after triggering the workflow

The script editor provides full autocompletion for all available services, methods, and entity properties — no guesswork required.

***

## Type Definitions

The in-app script editor already offers autocompletion. When you develop scripts — especially [Script Modules](https://developer.vario-software.de/documentation/scripting/script-modules.md) — locally in your own editor (for example VS Code), you can get the same IntelliSense and type checking from the [@vario-software/types](https://www.npmjs.com/package/@vario-software/types) package. It ships type definitions for the scripting interfaces, including the `ctx` object, `ctx.services`, and entity DTOs. See the package page for setup instructions.

The same package also provides types for the [REST API](https://developer.vario-software.de/documentation/rest-api/introduction.md#type-definitions).

## Deprecations

Use the Admin-Center’s **Auffällige Aufrufe** view to review reported uses of deprecated scripting elements. App developers can also review findings assigned to their App. See [Deprecations and usage findings](https://developer.vario-software.de/documentation/apps/deprecations-and-usage-findings.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.vario-software.de/documentation/scripting/introduction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
