# Introduction

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

***

## 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)

### Batch Processing

Data import scripts that process files row by row. Each row passes through a series of callbacks — `beforeImport`, `eachRow`, `afterImport` — 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. Imports 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)

***

## 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)

***

## Script Modules

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

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

***

## 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.
