Write and run a script¶
Goal: run a small TypeScript or JavaScript program against the active context —
read lists, filter them, act on many items — through the operation catalog (vf).
Prerequisites
- Signed in. Reads work for everyone; writes need an admin.
- The context to run on is active (the run button names it); on a protected context each write asks first.
Steps¶
- Open Config > Scripts (route
/config/scripts). - Start from an example: under Examples, click Stopped workers. The code appears in the editor (with an empty name).
-
Edit it. The operations you can call are listed under Operations (expand a group); catalog with input schemas opens the full catalog. For example:
-
Name it and Save (e.g.
stopped-workers). It appears under Yours (kept in this browser). - Run on
<context>. While it runs the button is Stop. - Read the result: Output has what it printed and the returned value as JSON (or
done); Operations called lists each call, ✓ or ✗, with its input, writes marked. - Writes: a call such as
await vf.workers.stop({ id })passes the write gate: on a protected context the dialog asks (a yes covers the writes of the next 5 s); a No makes that call throw.
What you should see¶
- Output lines as the script prints; the result at the end; errors in red.
- Each write in Infra > Changes.
Troubleshooting¶
| Symptom | Cause and fix |
|---|---|
| does not compile: … | A syntax error; types are allowed, imports are not. |
no operation <name> |
A misspelt vf.<group>.<action>: check the Operations list. |
<operation>: /<field> … |
The input does not match the schema; the message names the field. |
fetch fails / no network |
By design: the sandbox has no network. Reach the platform through vf only. |
| only admins may write | You are not an admin. |
| stopped after 10 minutes | The time limit: split the work, or read with smaller timeoutMs. |
| The script is gone in another browser | Scripts are kept per browser (localStorage); copy the code over. |
More: Scripts.