Friday, September 4, 2015

New feature: JavaScript as process dialect

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 {
} catch(err) {
    print(err + '\n');
// this is comment
print( + '\n');

Or a constraint like: == 'krisv'


  1. Hi krish..Could you please help me to understand the way I can query a local git repo path of a build process using REST call and a guide for java programming in script blocks.

    1. Scripts should in general only be used for simple manipulations (for example updating a process variable etc.). The docs contains some data on what you can do in scripts:

      For the other question, please try to use the mailing list / irc channel for this, as I'm not sure what you are trying to do. If you want to get access to files on the repos, the only way to currently do that remotely is through GIT (although I guess there are projects out there that could put a REST frontend on top of that).