Timill Platform Documentation

Scripting

Automate groups with JavaScript backend scripts, and build custom charts and widgets for pages.

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#

KindLanguageRunsCan change dataSet up in
Manual backend scriptJavaScriptwhen someone clicks Runyesgroup administration → Scripts
Scheduled backend scriptJavaScripton a cron scheduleyesgroup administration → Scripts
Event backend scriptJavaScriptafter items are created, changed or deletedyesgroup administration → Scripts
Save hookJavaScriptinside an item’s save, before the change is announcedyes, as part of that savegroup administration → Scripts
Item menu scriptJavaScriptwhen someone picks it from an item’s menuyesgroup administration → Scripts
Scripted chartJavaScripteach time the page is viewednoa page’s widget settings
Scripted widgetGonjaeach time the page is viewednoa 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 menuScripted chartScripted widget
user, groupread and writeread and writereadread
itemonly for an event raised by an itemthe itemwhen the page has onewhen the page has one
Items from group.queryItemsread and writeread and writereadread
pageVarsemptyemptythe page’s variablesthe page’s variables
fetch, secretsyesyes——
api helpersyesyesyesgroupBy, aggregate
echarts helpersyesyesyes—
logexecution historyexecution historythe chart’s Recent runsthe 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#

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.