I have a global Integer variable RANDOM_NUMBER
I just want to store the response from a service that returns a random number into that global variable. How do I do that in the workbench?
So basically RANDOM_NUMBER = result
Business process:
Variables:
Service Data I/O:
I think, but I can't say I tested carefully, that global variables are shared between processes or process instances and process data is available to a specific process instance.
EDIT: So you can save the result of a workitem into a process variable but you have to use code to access the global variables. See section 8.6.1. Variables of the documentation.
The issue will be that "result" isn't available as a variable in the context of the exit script. It's an output parameter of the workitem. So, in order to get the result of the workitem into a variable that then can be copied into a global variable create a process variable (in your case result though I'm not a fan of the duplicate name) and assign result to that, which it looks like you did.
So probably the script on the exit script of the REST workitem should be.
kcontext.getKieRuntime().setGlobal("RANDOM_NUMBER", Integer.parseInt(result.trim()));