Storing the result of an httptask in a resultVariablePrefix results in null.
this used to work in 6.2.1
A small test project can be downloaded here: httptest
This can be tested in the following example:
<serviceTask id="httptask" name="httptask" flowable:type="http">
<extensionElements>
<flowable:field name="requestMethod">
<flowable:string><![CDATA[GET]]></flowable:string>
</flowable:field>
<flowable:field name="requestUrl">
<flowable:string><![CDATA[http://192.168.1.65:8080/hello]]></flowable:string>
</flowable:field>
<flowable:field name="requestHeaders">
<flowable:string><![CDATA[Content-Type: application/json]]></flowable:string>
</flowable:field>
<flowable:field name="resultVariablePrefix">
<flowable:string><![CDATA[hello]]></flowable:string>
</flowable:field>
<flowable:executionListener event="end"
class="org.flowable.engine.impl.bpmn.listener.ScriptExecutionListener">
<flowable:field name="script">
<flowable:string><![CDATA[
print("test");
print(execution.getVariable("hello.responseBody"));
]]></flowable:string>
</flowable:field>
<flowable:field name="language">
<flowable:string><![CDATA[javascript]]></flowable:string>
</flowable:field>
</flowable:executionListener>
</extensionElements>
</serviceTask>
In 6.3.0 the prefix is prepended without a dot in between, so you should use execution.getVariable("helloResponseBody")
.
This was changed in https://github.com/flowable/flowable-engine/commit/d7554ebb572caa7e66933852362610041baefecc#diff-d66c51ccebf7d3aff06bc6143c8f7bf8
Anyone know why this was changed?
Will my current processes break when I upgrade to 6.3?
I believe it was changed to make it possible to use the variable names in JUEL expressions, see:
The Http task sets up many variables such as responseStatusCode with a dot notation.
execution.setVariable(request.getPrefix() + ".responseStatusCode", response.getStatusCode());
Using dots in variable names makes life hard in JUEL expressions. This could have been solved if the default prefix itself included the dot, then putting a custom result prefix without it could have helped, but now there is now way to avoid it.
I couldn’t find a way to escape the dot in UEL, so I needed to get the va…
I guess you have to update your processes before upgrading to 6.3.
@tijs I think it would be helpful if this behavior change was added to the 6.3.0 release/update note. What do you think?
Upgrading the processes is the least of my concerns. What about process instances that are running.
Since this change is probably not backwards compatible, running (active instances ) processes will break.
joram
May 3, 2018, 1:13pm
7
Indeed, if they depend on the variables to be in the old format (for example on a sequence flow condition).
Is it an option to deploy the very same process definition, just with the condition expression change and then call SetProcessDefinitionIdCmd with the new version for all the process instances?
A work-around for this as follows if you use the result in scripts:
responseBody=execution.getVariable("httptaskResponseBody");
if (responseBody==null) {
responseBody=execution.getVariable("httptask.responseBody");
}