Blog Posts Process Management

New feature: JavaScript as process dialect

Blog: PROCESSES, RULES AND EVENTS

Since the 6.3.0.Final release is coming soon (we just pushed out second candidate release), there are quite a few exciting new features, and this blog will highlight one.
When defining your process logic, you can use scripts (small fragments of code) in various locations in the process definition.  You can use different languages (also called dialects) for this, and until now you had to choose between Java and MVEL as dialects (or if you’re an expert you could implement your own dialect) for action scripts and code constraints.
We have now also added support for JavaScript, which means you can write small fragments of JavaScript code as part of your process, both as action scripts (typically for manipulating variables) and constraints (in diverging gateways):
  • As action script:
    • Action script inside a Script Task
    • On-entry or on-exit actions scripts (in tasks supporting these, e.g. user tasks, call activity, rule tasks, etc.)
  • As constraint:
    • In diverging gateways (to decide which branch to take)

Inside these JavaScript fragments, you automatically have access to various properties (similar to how Java and MVEL actions scripts work):

  • Direct access to 
    • process variables
    • globals
  • A ‘kcontext‘ variable giving access to the ProcessContext (and through this you can get access to the active ProcessInstance, NodeInstance, KieSession, etc. and set variables)
To use the new dialect, simply select “JavaScript” as the script language (in one of the above describe situations), both in the web-based designer or the Eclipse Modeler.

For example, you could define an action script like:

kcontext.setVariable(‘surname’, “tester”);
var text = ‘Hello ‘;
print(text + kcontext.getVariable(‘name’) + ‘n’);
try {
    somethingInvalid;
} catch(err) {
    print(err + ‘n’);
}
// this is comment
print(person.name + ‘n’);

Or a constraint like:

person.name == ‘krisv’

Leave a Comment

Get the BPI Web Feed

Using the HTML code below, you can display this Business Process Incubator page content with the current filter and sorting inside your web site for FREE.

Copy/Paste this code in your website html code:

<iframe src="https://www.businessprocessincubator.com/content/new-feature-javascript-as-process-dialect/?feed=html" frameborder="0" scrolling="auto" width="100%" height="700">

Customizing your BPI Web Feed

You can click on the Get the BPI Web Feed link on any of our page to create the best possible feed for your site. Here are a few tips to customize your BPI Web Feed.

Customizing the Content Filter
On any page, you can add filter criteria using the MORE FILTERS interface:

Customizing the Content Filter

Customizing the Content Sorting
Clicking on the sorting options will also change the way your BPI Web Feed will be ordered on your site:

Get the BPI Web Feed

Some integration examples

BPMN.org

XPDL.org

×