How to pass a complex type in processAPI.startProcess
I want to pass a complex type to my process while I want to call the processAPI.startProcess but I totally don't know how to do this, I thought that maybe below code could help me but it couldn't.
Map<String, Serializable> inputs = new HashMap<String, Serializable>();
inputs.put("departureDate", new Date());
Map<String, Serializable> mainInputs = new HashMap<String, Serializable>();
mainInputs.put("travelRequestInput", (Serializable) inputs);
ProcessInstance processInstance = processAPI.startProcess(processDefinition.getId(), mainInputs);
and I got the below error:
org.bonitasoft.engine.bpm.process.ProcessExecutionException: USERNAME=jafari | org.bonitasoft.engine.bpm.contract.ContractViolationException: Error while validating expected inputs: [Expected input [travelRequestInput] is missing]
Right, in the javadoc of startProcess you'll see
Note: If the process instantiation contract requires inputs, you must use startProcessWithInputs(long, Map) instead, transforming initialVariables parameter as follows: in the process, define process variables initial values (expressions) with contract inputs.
ProcessInstance startProcessWithInputs(long processDefinitionId,
Start an instance of the process with the specified process definition id, and provides inputs to fulfill Process Contract. See ContractDefinition for details on contracts.
Parameters:processDefinitionId - The identifier of the process definition for which an instance will be started.instantiationInputs - The couples of input name/value that allows to start a process with an instantiation contract.Returns:An instance of the process.Throws:InvalidSessionException - If the session is invalid, e.g. the session has expired.ProcessDefinitionNotFoundException - If no matching process definition is found.ProcessActivationException - If an exception occurs during activation.ProcessExecutionException - If a problem occurs when starting the process.ContractViolationException - If inputs don't fit with task contract
Thank you so much for your note.
yes you were totally right, but I expected for a more clear documentation from Bonita not just a Java doc.
anyway your comment were so help full and exactly what I was asking for.
Yes,I have read this before, but I'm asking for an example if you have ever tried as the documentation is not clear enough.