I have initiated the process programmatically from the backend. The first task is to enter order details. How can I add initial data programmatically to the process document from the backend?
eventPublisher.publishEvent(new ProcessBeforeStartEvent(processDefinition, businessKey, variables));
ProcessInstanceDto processInstanceDto = camundaRestClient.startProcessInstance(processDefinition, businessKey, JsonConverterKt.convertJsonToCamundaMap(jsonNodeFromString));
eventPublisher.publishEvent(new ProcessAfterStartEvent(processDefinition, businessKey, variables));
Hi @n.garryyev,
If the process is supposed to start with existing data, you’ll have to create a document beforehand. Once you have the DocumentReference, you can simply pass it to the START_PROCESS request via the variables, e.g. "myOrderDocRef" with value theDocumentReference.toString().
Then, the user task must have an Input defined in the BPMN model which references the docRef:

Hope that helps!
Peter
Hi @psommerhoff,
This is clear, thanks.
But is it possible to pass a variable to a Form? For example, I pass the “email” variable to the START_PROCESS, and then I want to set it to the Form field labeled “Email Address”? Furthermore, I would like to achieve this with not an existing document.
Hi @n.garryyev , am I understanding you correctly that you want to add initial data to the document that is created by Camunda during the process? This is not supported by Workflows from a modelling perspective, but you could try reacting to Dataservices events that are fired on document creation by registering an event listener in Dataservices. Alternatively, there is a setting for initial values in your form models that you can use to set default values that would at least save users from having to retype this email address.
If you only need this email address to pass some kind of validation, you should instead try to use context-based validation rules to allow for the creation of empty documents (see warning at the end of this section)
Regards
Oliver