BProc: creating a script task to change a process variable

Hello,
I am trying out the new BProc addon. In a process modeler I set form type to Input dialog and added a process variable, I decided to create a simple script in order to change the value of the variable.

There is no information about scripts in BProc official documentation, though in the previous BPM documentation I could find a few words about it.

Could you provide some information and examples of creating scripts with BProc. In my case the script is to change the value of process varriable (string type)

I am looking forward to fast reply.

Hi,

BProc doesn’t add anything to ScriptTask functionality provided by the Flowable engine. The Flowable documentation says:

All process variables that are accessible through the execution that arrives in the script task can be used within the script

It’s also possible to set process variables in a script, simply by calling execution.setVariable(“variableName”, variableValue)

So just type

execution.setVariable(“variableName”, variableValue)

in the Script field of the ScriptTask.

It will be useful to have this information also in the BProc documenation, we’ll add it. Thank you for the hint.

1 Like

Max, thanks for your reply, I have tried to set the script in the same way and typed:

execution.setVariable(“state”, rejected)

where “state” is the variable name and rejected is it’s supposed value (state is a string type)
So here is a error during the process execution:

MissingPropertyException: No such property: rejected for class: Script36

Max, I appreciate your reply and want to find a proper solution for this problem, providing some screenshots.%D0%91%D0%B5%D0%B7%D1%8B%D0%BC%D1%8F%D0%BD%D0%BD%D1%8B%D0%B9 1

The script language is Groovy, so if you need regular strings put text literals in single quotes:

execution.setVariable('state', 'rejected')

Groovy documentation for strings: The Apache Groovy programming language - Syntax

Finally the script works as it’s supposed to do, Many thanks, Max!

i hava a question ,i cant use this “ @Autowired
private VariableService variableService;”
why?