Guide / Draw and edit
Scripts in their own tab
Edit a script or an expression from an element as a real file in your tool's own code editor, with its colours, completion and checks. The script tab page says what the tab knows about your variables.
Why
The small editor in the properties panel is fine for one line. For a longer script you want a full code editor. Penstock hands the script to your tool as a file and writes every keystroke back into the diagram.
It is a tab that knows where in the process the script sits: which variables reach it, which step writes each one, and, for a FEEL expression, a syntax check, documentation and a Run with sample values. That part is on The script tab. This page is about opening and closing it.
Steps
- Select a script task, or any element that holds a script or an expression: a condition, an input or output mapping, an execution listener or a task listener. On Camunda 8 that is a FEEL expression, one that starts with
=, in a condition or a mapping. - In the properties panel, find the script field. Under it is a button Edit in new tab. Press it.
- A code editor opens with the script as a file:
.groovyfor Groovy or.jsfor JavaScript. A FEEL expression opens in the same way, with FEEL colours and checks. - Type. Your changes go back into the diagram about 100 milliseconds after each keystroke, and reach the diagram model 400 milliseconds after you stop.
- Close the editor when you are done.
In your tool
JetBrains
The IDE opens a new editor tab. Because the file has the extension .groovy or .js, the IDE's own colours, completion and inspections apply. Pressing the button again brings the existing tab to the front.
VS Code
VS Code opens a new editor tab beside the diagram, whose extension is that of the script's language, such as .groovy or .js. Pressing the button again brings the existing tab to the front. Closing the tab brings the text back to the property. The tab is not a file on disk and cannot be renamed.
Command line
Not available on the command line. The command line has no editor. Edit the script in the diagram file, or with penstock edit.
What you see
- While the script is open, the field in the properties panel is read-only. There is exactly one place to type.
- The script is a temporary file kept in memory. Nothing is written to your disk.
- When you close it, the field in the panel becomes editable again.
- If you press the button again while the script is open, it says Show tab, and that editor comes to the front. It does not open a second one.
The default language
Set scriptType in penstock.yaml to groovy, javascript or none. It is used for a script that has no format yet, and for a condition expression that has no language yet. It applies to Camunda 7, Operaton and CIB seven only. See penstock.yaml.
Common problems
- There is no Edit in new tab button.
- The field holds a plain value, not a script or a FEEL expression. On Camunda 8 only a FEEL expression, one that starts with
=, has the button, and a script resource that lives in a separate file is edited in that file. - The code is coloured as the wrong language.
- The script format is JavaScript or Groovy as set on the element. Change the script format in the panel and open the script again.
- I closed the script and lost text.
- You did not lose it. Everything you typed was already written back into the diagram. Undo in the diagram if you need an older version.