Java delegate - how to get "form element" from execution


In a Java delegate class, I would like to know if available variables (execution.getVariables()) came from the form of the previous flow element (i.e: start event or user task).

I’m able to retrieve the previous flow element with the following code :

FlowNode currentElem = (FlowNode) execution.getCurrentFlowElement();
FlowElement previousElem = ((SequenceFlow) currentElem.getIncomingFlows().get(0)).getSourceFlowElement();

At first glance, having the previous flow element “of the form” should not be enough to get the instance definition of the form (or something like that, sorry for the wrong terminology)… Indeed, I can get the FORM_KEY (previousElem.getFormKey()), but this is the one enterred by the end user in the UI modeler, not the internal reference of the form used, right?

Finally, in this use case, how can I get the form definition / instance (in order to know the input names which are used as variable name)?


That’s not possible (variables can for example also be shared over many forms). The only way to do so would be to prefix your variables of the forms with something unique to the form.

Ok, thank you for your reply.

However, if we just want to know if a variable come from a form, whatever which one, is that still possible?
Concretly, I want to send variable data to an external services, but only ones which come from forms…

I’m looking for a way of getting the formService, in order to do something like “formService.getTaskFormData(myElem.getId()).getFormProperties();”…

But I’m maybe on the wrong way?

@ychab i am facing the same problem.
May i know how did you resolve it ?