Using ES6 in Script task

Hi,

I’m wondering if there is any way to configure either Flowable or the underlying jvm such that ES6 features/syntax can be used in script tasks when using JavaScript? In general I can use script tasks without issue but if I include an arrow function () => or other ES6 syntax the script task fails at runtime.

I’ve tried a few things unsuccessfully and don’t want to waste anymore time if it’s not possible.

Thanks,
Dan

The javascript engine that is used is the one that is determined by the underlying JDK running Flowable. In recent JDK releases, this is Nashorn. There seems to be some ES6 support for Nashorn: https://stackoverflow.com/questions/48038418/ecma-6-support-in-nashorn, but haven’t tried it myself.

Hi,

Thanks for the info. I came across a similar article (or maybe the same one) and traced it down to the Nashorn engine settings as well. I had previously tried configuring the nashorn argument -Dnashorn.args=--language=es6 via the Tomcat setenv.sh script when starting flowable and thought it didn’t work but it turns out it wasn’t getting applied correctly. As an interim test I set the argument as a JAVA-OPT rather then using the setenv script and the ES6 syntax in my script task worked as expected. I did need to ensure I had at least 1.9 for my underlying JDK. I tried it with 1.8 and the script couldn’t be evaluated. 1.9 and 12.02 worked just fine.

Thanks,
Dan

It does look like the support only starts from JDK 9. But cool to hear it works! So you can use "() => " syntax without compromises in a script task that way?

Yes it’s pretty cool. Template literals also work using back ticks. So something like Thank you ${name} for your request for ${requesteditem} can be evaluated in a script task rather than concatenating strings together though usual checks for variable existence still need to be used. I haven’t yet tried the builtin flowable variable functions like ${var:get(myVariable) in that context.