Getting process variables into external form

Hello,

i have a problem and i hope you can help me with this issue.

The Situation:
I start a process instance with an external form (html with javascript) in which i enter some data.
I am right at the beginning so i am testing with only one value, this is “name”.
So i enter the name in the form and with a button pressed a process instance is started with this value.
I start the process instance with a REST call via fetch() in my JavaScript, where i put the value of the field “name” as a variable in JSON format in the body.

This works fine as i see the instance and the process variable in cockpit.

After the start event comes a user task in which the data should be approved. So in this case only the entered name.
The user task got an external form too and now i want to show the process variables of the process instance in this external form.

Can you tell me how i can do this? I know that there is a REST call for getting the process variables from a process instance id.
But how can i get this instance id? Is it possible to get the instance id from the tasklist URL when the user opens the external form , so i can do a GET REST call when loading the form?

Or do you know a better solution in general to work with external forms?
I feel like i am missing a big point here.

I am using the tomcat pre-packaged distribution, so JSF is not an option i guess.

Thanks for your help.

Hi @LowkiGG,

when you query for tasks (https://docs.camunda.org/manual/7.12/reference/rest/task/get-query/) or get the task details (https://docs.camunda.org/manual/7.12/reference/rest/task/get/), you will get the process instance id for each task.

Hope this helps, Ingo

Hello and thank you for your fast reply.

I had a look at your links and when i understood it right, i need some information, at least about the task itself, to get the process instance id.

But my external form has no information about anything from any process instance or task.
I dont know how to get the process variables of the instance into my external form.

Can i get the task information when i open the external form or is there maybe a better way for working with external forms in html/js in general?

Hallo,

i really missed a big point here :smiley:
Thanks for your help, yesterday i didnt really understand what you were trying to tell me.

Of course i can get the task id from the url and then get the variables via REST Call. Thank you for your help. This works fine for me.

So there is no better way when working with external forms?

Hi @LowkiGG,

No, this is the most generic and technology agnostic approach.

Hope this helps, Ingo