0

How do I use the flw library in flowable script task? Using community version of flowable, 3.x and in my script task I want to use the flw library.

https://documentation.flowable.com/latest/develop/be/be-scripting#:~:text=A%20JSR-223%20compliant%20scripting%20language%20like%20JavaScript%20or,output%20parameters%2C%20depending%20on%20your%20context%20of%20course.

I cannot find any good documentation or examples and when I try to use some commands in my script task I get a "error" executing the workflow from flowable work. ANyone else having this problem and know how the get around it.

Basically I want to use the flw library to get, set, and manipulate variables and data payloads in my workflow and I don;t want to write and compile java code, I just want to use the platform as a end user.

thanks mark

within my script task

var myjson = flw.getInput('restResponse');

var x = flw.setOutput('v1', 24);

in flowable work I get an error when I run the workflow. When I remove this code from the script task it runs fine

also read this in their document

The scripting API also supports various utilities around JSON object handling like creating a JSON object or array or converting a JSON string into a JSON object structure.

You can access those utilities through flw.json.

what are the functional available via the flw.json library and how do I see the function signatures.

1 Answers1

1

When you would like to use the documentation you have referred, you need to have the Flowable Work or Flowable Engage version. Those methods do not apply to Flowable Open Source or Flowable Orchestrate.

In both cases, you need to ensure that the variable restResponse does exist on your process or case. Also, you should have a more detailed error message in your server logfile.

Since you mentioned that you have Flowable Community Edition, I assume it is Flowable Open Source (however, there the version would be 6.x). In this case, the script would look like this (for BPMN only):

var myjson = execution.getVariable('restResponse');

execution.setVariable('v1', 24); 

In case you are using Flowable Work the script as you mentioned it, is almost correct, in this case you can just remove the assignment of the setOutput, since there is no return:

var myjson = flw.getInput('restResponse');

flw.setOutput('v1', 24);

This would work for BPMN and CMMN with Flowable Work. With Flowable Work you should see the errors as well when you enable and open Flowable Inspect.

For the JSON utilities you mentioned, you have an overview of the available methods on the page when you scroll down, including the signature: https://documentation.flowable.com/latest/develop/be/be-scripting#available-methods

  • thanks Valentin, I am launching the process using flowable work. Follow up question, and yes all variables referenced in the script task are initialized in a task or explicitly declared in the script. is this allowed var x = flw.getInput('jsonstructure'); x.size(); to get the size of the json structure or array? – user20627766 May 25 '23 at 11:44
  • Indeed, see also [the reference in the documentation](https://documentation.flowable.com/latest/develop/be/be-scripting#available-methods) in which `size()` is explained. – Valentin Zickner May 26 '23 at 13:32