Hello to all,
I need to start a process with a form. For example:
request for practice opening, if you do not finalize the request I don’t want that start a process instance.
I would like to show a form first, present in the bpmn, after which the process starts if the user continues after the above-mentioned form.
I noticed that it is possible in the modeler task to start a process with a form. If you put a form key on the startevent, it shows the form, then after clicking on start process you start it, and that’s exactly what I need. How does it work?
Well you can get the form and also render it yourself via the forms REST api (/form-api/form/model) then on form submission, start the process with the submitted variables via the process api(/process-api/runtime/process-instances) REST api.
I am struggling with the same problem in REST API. You can get the Process/Case definition and it has field “hasStartForm: true” to tell is if the process/case has start form but so far I have not found any way to get the formKey form the API. Apart from pulling the whole definition XML greppit the test from inside the XML.
Most of the REST API is of no use as it only deals with instance ID’s and prior of starting the process/case there is no instance.
Or am I getting to usage wrong? for case definition has that start form am I supposed to start the case and then render the start form in my UI ? But is’nt that problematic as then engine has already started processing the case without the prerequirement data in the start form ?
As I understand to flow :
get case definition
if definition has start form , get the start form definition(model). HOW do I do that ?
render the start form for user input
submit that data as POST to the case-rutime/instances endpoint with the form values as variables
Get the case/process definition form API GET cmmn-repository/case-definitions/{caseDefinitionId}
Check if it has “startFormDefined”: true
if it does then get GET cmmn-repository/case-definitions/{caseDefinitionId}/resourcedata
from that use regexp to get /<casePlanModel .? formKey="(.?)"/
get the form definition by key GET form-repository/form-definitions?key={formKey}
get the actual form definition with fields by id GET repository/form-definitions/{formDefinitionId}/resourcedata
Render the form (as Flowable supports external forms a good idea in to use the https://jsonforms.io/
it gives you ready made renderers. And when actually startign the case/process do it normally POST cmmn-runtime/case-instances
but put the form data into the reguest body variables section:
{
"caseDefinitionKey":"testCase",
"businessKey":"myBusinessKey",
"tenantId": "tenant1",
"variables": [
{
"name":"myVar",
"value":"This is a variable"
}
]
}
NB: You need to deconstruct the key-value data into {“name”: ${key}, “value”: ${value}} for the variables section.
It doesn’t look like it’s implemented (it is in the custom REST API of Flowable Task, but not as public API). There is a Java API ( FormInfo getStartFormModel(String caseDefinitionId, String caseInstanceId)) that does this, but it doesn’t seem to be exposed over REST.