Hi All,
I am trying to pass some values and start a process from a java app but not sure how do I access them in the form.
(To view the the image below, right click and choose open in a new tab)
<p><img alt="test" src="https://ibb.co/BTvQ5dP" style="width: 100px; height: 100px;" /></p>
Here is the java code:
HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("server.url", "http://localhost:8080");
parameters.put("application.name", "bonita");
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, parameters);
LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
// log in to the tenant to create a session
APISession apiSession = loginAPI.login("walter.bates", "xxx");
// Process API
ProcessAPI processapi = TenantAPIAccessor.getProcessAPI(apiSession);
IdentityAPI identityAPI = TenantAPIAccessor.getIdentityAPI(apiSession);
User user = identityAPI.getUserByUserName("walter.bates");
//Find the List of deployed processes
final SearchOptions searchOptions = new SearchOptionsBuilder(0, 100).sort(ProcessDeploymentInfoSearchDescriptor.DEPLOYMENT_DATE, Order.DESC).done();
final SearchResult<ProcessDeploymentInfo> deploymentInfoResults = processapi.searchProcessDeploymentInfos(searchOptions);
Map<String, Serializable> variables = new HashMap<String, Serializable>() ;
variables.put("varA", "test");
variables.put("varC", "testa");
try {
long processDefinitionId = processapi.getProcessDefinitionId("TestPool", "1.0");
// ----- create list of operations -----
List<Operation> listOperations = new ArrayList<>();
Map<String, Serializable> listVariablesSerializable = new HashMap<>();
for (String variableName : variables.keySet()) {
Object value = variables.get(variableName);
if (value != null && value instanceof Serializable) {
Serializable valueSerializable = (Serializable) value;
variableName = variableName.toLowerCase();
Expression expr = new ExpressionBuilder().createExpression(variableName, variableName, value.getClass().getName(), ExpressionType.TYPE_VARIABLE);
Operation op = new OperationBuilder().createSetDataOperation(variableName, expr);
listOperations.add(op);
listVariablesSerializable.put(variableName, valueSerializable);
}
}
// ----- start process instance -----
processapi.startProcess(processDefinitionId, listOperations, listVariablesSerializable);
But I am not sure how to access variables, varA and varC in BPM flow, ie in Human task or is it even correct what I am doing. If not how can I access those variables in the human task form after I start the process from Java app
(To view the the image below, right click and choose open in a new tab)
<p><img alt="test" src="https://ibb.co/P6JHFcS" style="width: 100px; height: 100px;" /></p>
Appreciate any help.
Thanks