because I want to implement an external UI I want to query the form variables of a user task via rest. From the documentation, this should be possible with the endpoint
/task/{id}/form-variables
where id is the TaskId.
However when I try this endpoint I get unexpected responses.
In my first scenario i tried embeded form variables. To do that I created a simple testprocess:
(the bpmn files are at the end)
Note that “start” has the form variable test1 and “Do Something” has the form variable test2.when I start this process and query the endpoint, I get the variables test1 and test2.
This is a problem, because I wanted to only get test2.
Because I thought this might be an issue with embededvariables due to form keys or something similar I did a second test scenario this time with camunda Forms. Again we have the same basic diagramm:
However this time “start” and “Do something” have camunda forms with them with the fields "formtest1"on start and “formtest2” on “Do something”.
When I know query the endpoint I again did not get “formtest2” but “formstest1” o_O
Now I am a bit in dead water and dont know how to do this.
How do you get Form variables for a user task?
Technical Data:
Camunda 7.17
(Because the forum only allows one upload here are the files as a download link) testFiles
Hi Thomas,
Trying to understand your problem statement correctly.
I am attaching the BPMN file.Please review and kindly let me know if this what you’re trying to achieve. FormInput.bpmn (2.7 KB)
Thanks,
Nandan
Hi Nandan,
first i was a bit confused why this process worked differently than my process bpmn from the original post, however than i realised that you arent writing the first forms variable as a variable to the process instance but as the business key. changing this or adding a variable to the running instance however again gives back more variables than wanted
Hi Thomas,
Now I am able to replicate your problem statement.Point is if you go through the below links for process variables it clearly states that a variable defined at parent scope is visible everywhere and that’s the issue you’re facing.https://docs.camunda.org/manual/latest/user-guide/process-engine/variables/
The only way out I see is to filter form variables with the variable name which I definitely know isn’t the right way of dealing with this requirement.
Hi,
yeah i understand variable scopes. however i though that the endpoint form-variables only returns form variables, as stated in its description:
Retrieves the form variables for a task. The form variables take form data specified on the task into account. If form fields are defined, the variable types and default values of the form fields are taken into account.
In my current understanding this is a bug, so i am looking for a workaround. A possible solution i have come up with is just writing all variables into a dedicated variables variable, that than again is a list of json variables. this feels … wrong.
Another way could be to define a local variable, that defines a commaseperated listof variable names to filter by, however i could not add a local variable to the camundaTask, that i was able to querry through the get list endpoint of the local variables of a task yet