Camunda Model API Trying to add Map element to Input Parameter

I’m trying to use the Camunda Model java api and I’m having a problem adding a Map element to an input parameter. I’m actually unable to add any child element to the input parameter. I get a Model exception that says “New child is not a valid child element type: map; valid types are: []”

Am I doing this incorrectly? Or is this not supported from the API?

Here is the code I am trying to execute:

    ModelInstance modelInstance = elementBuilder.getElement().getModelInstance();

    CamundaEntry entry = modelInstance.newInstance(CamundaEntry.class);
    entry.setCamundaKey("Test1");
    entry.setTextContent("test2");

    CamundaMap map = modelInstance.newInstance(CamundaMap.class);
    map.addChildElement(entry);

    CamundaInputParameter inputParameter = modelInstance.newInstance(CamundaInputParameter.class);
    inputParameter.setCamundaName("initialVariableDefinitions"); // this is the process variable being created to hold all the defn var defbitions
    inputParameter.addChildElement(map);

    CamundaInputOutput inputOutput = modelInstance.newInstance(CamundaInputOutput.class);
    inputOutput.addChildElement(inputParameter);

    elementBuilder = elementBuilder.serviceTask("initVariables_1")
            .name("initVariables_1")
            .camundaClass("com.test.bpm.engine.camunda.servicetasks.VariableInitServiceTask")
            .camundaExecutionListenerClass("start", "com.test.bpm.engine.camunda.eventlisteners.NodeEnterListener")
            .addExtensionElement(inputOutput);

According to the extension elements documentation it should support list map and script as child elements.

Try to use inputParameter.setValue(map).

1 Like

Thanks that worked for me. I didn’t notice that API. It’s actually doing what our workaround did.