I did find any way to define case input parameters to set during case creation in case modeler.
Is it possible or not in Camunda ?
Is it a way to define required input parameters ?
What is the way to create case variables ? (case variable listener may be).
Thanks for help.
It sounds like you’re referring to an HTML case form. I can follow-up on that later. But, here’s a Java API example - showing the Camunda SDK interaction with a “start-case” scenario.
Starting a case with JSON formatted values received via a JAX-RS post
I tend to use a facade pattern to help simplify external ReST clients - simplifying the ReST API requirements for integration developers.
ReST POST payload
{
"caseID": "case_simple_01_cid",
"processVariables": [
{
"name": "hello",
"value": "greetings Camunda Case"
},
{
"name": "myName",
"value": "Joe Smith"
},
{
"name": "customer",
"value": "Bob"
}
]
}
Loading and starting a case
// get case ID
// NOTE: Using the "General -> Case Id" field value from the CMMN case model
String caseID = postpayload.findValue("caseID").asText();
LOGGER.info("*** caseBasicStart - caseID: " + caseID);
// get the case/process variables
final JsonNode arrNode = postpayload.get("processVariables");
Map<String, Object> variables = new HashMap<String, Object>();
for (final JsonNode jsonNode : arrNode) {
variables.put(jsonNode.findValue("name").asText(), jsonNode.findValue("value").asText());
}
// start the case
CaseInstance caseInstance = caseService
.withCaseDefinitionByKey(caseID) // NOTE: this is the field value from General -> Case Id field
.setVariables(variables)
.create();
String ciid = caseInstance.getCaseInstanceId();
LOGGER.info("*** caseBasicStart - case started - ciid: " + ciid);
LOGGER.info("*** caseBasicStart - case is active: " + caseInstance.isActive());
1 Like