Scripts let a group do what its configuration alone cannot: react to changes, keep fields consistent, talk to external services, and show data the built-in widgets do not.
There are two languages:
- JavaScript for everything that runs on its own or changes data — backend scripts — and for scripted charts.
- Gonja, a Jinja-style template language, for scripted widgets, which render HTML inside a page tile.
Both see the same objects under the same names — user, group, items with getField — so moving between them is mostly a matter of syntax.
Kinds of scripts#
| Kind | Language | Runs | Can change data | Set up in |
|---|---|---|---|---|
| Manual backend script | JavaScript | when someone clicks Run | yes | group administration → Scripts |
| Scheduled backend script | JavaScript | on a cron schedule | yes | group administration → Scripts |
| Event backend script | JavaScript | after items are created, changed or deleted | yes | group administration → Scripts |
| Save hook | JavaScript | inside an item’s save, before the change is announced | yes, as part of that save | group administration → Scripts |
| Item menu script | JavaScript | when someone picks it from an item’s menu | yes | group administration → Scripts |
| Scripted chart | JavaScript | each time the page is viewed | no | a page’s widget settings |
| Scripted widget | Gonja | each time the page is viewed | no | a page’s widget settings |
Backend scripts are covered in Backend scripts; charts and widgets in Scripted charts and Scripted widgets.
What each kind can use#
| Automation (manual, scheduled, event) | Save hook, item menu | Scripted chart | Scripted widget | |
|---|---|---|---|---|
user, group | read and write | read and write | read | read |
item | only for an event raised by an item | the item | when the page has one | when the page has one |
Items from group.queryItems | read and write | read and write | read | read |
pageVars | empty | empty | the page’s variables | the page’s variables |
fetch, secrets | yes | yes | — | — |
api helpers | yes | yes | yes | groupBy, aggregate |
echarts helpers | yes | yes | yes | — |
log | execution history | execution history | the chart’s Recent runs | the widget’s Recent runs |
Every script runs as a user and has that user’s permissions: queries return only what the user may see, a field the user’s roles hide reads as empty (getField, the item’s properties, renderField and readAttachment alike), and a write to a field the user cannot edit is refused. Which user that is depends on the trigger — see Backend scripts.
Reference#
- JavaScript API — every object and function available to JavaScript.
- Gonja reference — the template language used by scripted widgets.
- Field values — what
getFieldreturns andsetFieldaccepts for each field type. - Files and attachments — reading, adding and removing files, and moving them through
fetch. - Query language — the syntax of
group.queryItems. - Limits and errors — time, memory and API-call budgets, and where failures show up.
- Cookbook — ready-to-adapt examples for each kind of script.
The script editor offers autocomplete for the whole API, a cheatsheet with the cookbook’s examples, and an AI assistant that writes and explains scripts.
Security#
Scripts run on the server in a sandbox. They cannot read the file system, start processes or load code, and fetch cannot reach private or loopback addresses. Secret values are stored encrypted and never written to logs by the platform. Each run has a time, memory and API-call budget — see Limits and errors.