Penstock

Guide / Draw and edit

The script tab

A script or an expression of an element opens in a tab of its own, beside the diagram. The tab offers the variables of the process, says which step writes each one, checks FEEL as you type, and runs a FEEL expression on sample values.

Free The findings about variables need Pro, and Team in a pipeline

What it is

A task, a flow, a listener or a mapping can hold a small program: a Groovy or JavaScript script on Camunda 7, a FEEL expression on Camunda 8. A short one is fine in the properties panel. For anything longer, you want a real editor, and you want to know what the variables are. The script tab is that editor. It knows where in the process the script sits, so it can say which variables reach it and which step wrote each one.

Your changes go back into the diagram as you type. Nothing else is written to disk. How a script is handed to your tool's code editor is described in Scripts in their own tab. This page is about what the tab knows.

What opens in a tab

WhereCamunda 7, Operaton, CIB sevenCamunda 8
A script taskThe script, in Groovy or JavaScriptNot offered
A condition on a flowA script conditionA FEEL condition, an expression that starts with =
A listenerThe script of an execution listener or a task listenerNot offered
An input or output parameterA parameter that holds a scriptNot offered
An input or output mappingNot offeredA source that is a FEEL expression, starting with =

A script that lives in a separate file (a script resource) is not opened. The file is the place to edit it.

Open it

  1. Select the element, or the flow, that holds the script or the expression.
  2. In the properties panel, find the field. Under it is the button Edit in new tab. Press it.
  3. The tab opens and is named after what it holds: the element and then the kind, as in Check stock - script, Approved - condition, Charge card - input amount or start listener. When two elements have the same name, the tab adds the id in brackets.
  4. While the tab is open, the button says Show tab and brings it to the front. The panel says This script is open in a tab.

The project view lists the same scripts in a Scripts branch under each process, in the order the process reaches them, and a click opens the tab.

The variables of the process

The tab shows the variables that exist at that step. Penstock works them out from the whole process: input and output mappings, result variables, conditions, form fields, message correlation keys, called processes and, when it can read them, the workers behind the tasks. For each variable you see:

A summary above the editor starts with Context and names the variables, and Show all lists them with their types and the steps that set them. In the editor, completion offers them as you type, hovering a name shows its type and who sets it, and where your tool can jump, the name leads to the element or the line of code that writes it.

Variables typed from the code

When a task is run by a worker or a delegate, the variables its code reads and sets are part of the answer, with their types and their fields. So a completion after order. offers the fields of the order the worker really returns.

Java, Kotlin, Groovy, JavaScript, TypeScriptRead by the code model of the tool where it has one, and otherwise by the reader of the command line. VS Code and Penstock Web and Desktop use the reader of the command line for every language.
Python, Go, C#, ScalaRead through the penstock command line. A tool that has no reader of its own for them finds the command line on the PATH or in the project's node_modules, or at a path you set.

Typed completion and the variables of the whole process are free. The findings that compare the diagram with the code are Pro, and Team in a pipeline:

The findings are in the Code group of the Problems tab. See Code links.

FEEL in the tab

A FEEL expression, such as a condition or a mapping on Camunda 8, gets four things that a plain text field does not.

Syntax checkA mistake is underlined with a sentence about it: FEEL compares with =, not ==, A name with spaces needs backticks, An if needs an else, This bracket is never closed. Some come with a fix, Replace with =.
CompletionThe variables of the process, and the FEEL built-in functions with their signature.
DocumentationA built-in function is explained next to its name.
RunPress Run or Run expression. Penstock asks for a sample value for each variable the expression reads: JSON, or a FEEL expression such as order.total * 2 for a value you have to compute. A variable left empty is not set. The result appears under the expression. With a Camunda 8 engine connected, the engine evaluates it and the result says Result from engine. Without one the expression is evaluated in the editor and the result says Result from preview.

In VS Code, and in the tools that have a debugger of their own, a FEEL expression can also be debugged step by step through its sub-expressions, with the value of each one shown beside it. Every FEEL field keeps its own undo and redo. The FEEL fields of scenario conditions, Camunda 8 conditions and the output cells of a decision table offer the project's variables.

Only FEEL runs in a tab of Penstock Web: for a Groovy or JavaScript script the tab says Only a FEEL expression runs here. Groovy and JavaScript scripts run in the engine, as part of the process. A tool that has a Groovy runtime and a debugger of its own can run and debug a Groovy script on sample values too. What each tool gives is on its own page, linked at the foot.

Go to code, Runs in and usages

The same reader powers the links between a step and its code. Go to code, Runs in and the usages of a job type, a topic or an error code, at each line that raises it, work for Python, Go, C# and Scala workers through the command line, and, in tools that read code with a code model of their own, for Java, Kotlin, Groovy and JavaScript code. These links are Pro, and Team in a pipeline. Going from a Camunda 7 delegate to its class or bean stays free. See Code links.

What you see

Common problems

There is no Edit in new tab button.
The field holds a plain value, not a script or a FEEL expression. A FEEL expression starts with =.
A variable is missing from the list.
Nothing before this step sets it, or the code that sets it is in a language or a place Penstock does not read. Name the other repository under linked in penstock.yaml, and see Code links.
The variables of a Python, Go, C# or Scala worker are missing.
The tool could not run the penstock command line. Install it with npm, or set its path in the tool's Penstock settings. A command line that is only in the project's node_modules runs only when you have trusted the project.
Run says the expression could not be run.
A sample value is neither JSON nor a valid FEEL expression, or it reads a name that has no value. The message names the variable.