Editing business process scripts in a visual code editor

🌐 This document is available in both English and Ukrainian. Use the language toggle in the top right corner to switch between versions.

1. General description

The developer of the registry regulations can edit Groovy scripts using the visual code editor in the embedded BPMN.iO diagram editor. The solution implements the Monaco Editor, visualized with the Visual Studio Dark theme.

The solution provides an enriched web code editor (a simplified version of an IDE development environment) that significantly enhances working with Groovy scripts in business processes. The tool supports essential functions for working with source code, allowing you to create and edit scripts in a single place—the script tasks of the registry’s business processes, without the need for external desktop applications.

The following features are supported when working with the editor:
  • Autocompletion

  • Autocompletion for custom functions

  • Syntax code analysis and error checking

  • Comment support

  • Code folding and unfolding

2. Functional capabilities

2.1. General usage process

Use the visual code editor when creating and editing scripts within the scope of business process modeling.

Editing components of the registry regulations is only possible within change candidate versions. For the master version, only the viewing option is available.

For more details on working with versions of the regulations, refer to Managing registry regulations versions.

  1. In the Regulations administrator portal, open the Process models section.

    process models 1

  2. Within the candidate version, select the process and click the 🖉 edit icon.

    process models 6

  3. Navigate to the Builder tab and model the business process in the web editor.

    The capabilities of the Builder tab are described in more detail at Modeling business processes in BPMN editor.

    process models 4

  4. Create a script task (Script Task).

  5. Click Open script editor to open the Script editor.

  6. Create or edit the script.

    Expand the editing window or view the script in full-screen mode for convenience.
    • Click Save to save the changes.

    • Click Close to cancel the changes.

      hierarchical model bp 2
      hierarchical model bp 3

      If the script contains any potential errors, the editor will provide a corresponding message on the screen.

      edit groovy scripts 6

2.2. Code autocompletion and custom JUEL function autocompletion

When working with scripts in the modeling editor, you can utilize code autocompletion, including autocompletion for custom JUEL functions from the dropdown list. This helps prevent errors during manual parameter entry.

2.2.1. Code autocompletion

The built-in intelligent completion features predict a data type and flow and suggest parameters based on the context. For example, prompts for possible methods used in variables, function completions, and more.

edit groovy scripts 1 1

2.2.2. Autocompletion for custom JUEL functions

The built-in intelligent completion features also include autocompletion for custom JUEL functions that enhance business process capabilities and facilitate modeling.

Use platform JUEL functions to simplify business process modeling. Currently, the following functions and their autocompletion are implemented in the visual code editor:

  • initiator()

  • completer()

  • system_user()

  • submission()

  • sign_submission()

  • get_variable()

  • set_variable()

  • set_transient_variable()

  • process_caller()

  • message_payload()

  • save_digital_document_from_url()

  • get_trembita_auth_token().

For more information on using JUEL functions, please refer to JUEL functions in business processes.

edit groovy scripts 1 2

edit groovy scripts 1 3

2.3. Code syntax analysis and error checking

The editor supports code syntax analysis and provides explanations to detail errors.

When hovering over specific elements, such as a variable used in the script, the editor suggests the package and class it refers to.

edit groovy scripts 1

2.3.1. Critical errors

If the code contains a critical error made by the modeler, the editor highlights the error in red within the script and displays a corresponding explanation on the screen.

edit groovy scripts 2

edit groovy scripts 3

2.3.2. Non-critical errors

If the code contains a non-critical error made by the modeler, when hovering over the cursor, the editor highlights the error in yellow within the script and displays a corresponding explanation on the screen.

edit groovy scripts 4

edit groovy scripts 5

2.4. Code commenting

The built-in script editor allows you to add comments to the code. Comments provide clear explanations or annotations in the source code of the script/program. They are added to make the source code easier to understand for humans and are ignored by compilers and interpreters. This means you can "hide" parts of the program or specific lines from execution.

Use single-line or multi-line comments.

2.4.1. Single-line comments

Single-line comments start with // (double forward slash) and can be used anywhere within a line. Characters after // until the end of the line are considered part of the comment.

edit groovy scripts 7

2.4.2. Multi-line comments

Multi-line comments start with /* (forward slash followed by an asterisk) and can be used anywhere within a line. Characters after /* are considered part of the comment, including newline characters, until the first */ (asterisk followed by a forward slash) that closes the comment. Therefore, multi-line comments can be placed at the end or even within an expression, and so on.

edit groovy scripts 8

2.5. Code folding and unfolding

Use code folding and unfolding functions to make your code more readable and hide or reveal details of specific blocks as needed.

You can organize block structure using reserved statements such as def, for, if, else, and so on.

When hovering the cursor next to a specific statement (an open block), a switch will appear to allow you to fold it.

Unfolding switches are always visible. Simply click on one to show the details in the code block.

edit groovy scripts 9