Get input parameter content with model api

Hello
I would like to get the input parameters and the value of the input parameter from a script task with model API.
I use this code:

File file = new File("c:/my.bpmn");
		BpmnModelInstance modelInstance = Bpmn.readModelFromFile(file);

		ModelElementType taskType = modelInstance.getModel().getType(Script.class);
		
		Collection<ModelElementInstance> taskInstances = modelInstance.getModelElementsByType(taskType);


		for (ModelElementInstance script: taskInstances){
			System.out.println(script.getTextContent());
		} 

This I can get the script content. Do you have any idea how can I get the input and output parameters as well? (the parameters are defined as a Groovy script and I would like to get that content).
scriptExample.bpmn (3.1 KB)

From my example I would like to get anyhow the input1 and the println “input1”.

Thank you very much your help in advance.

Gábor

Hi Gábor,

Input/output parameters are extension elements of script tasks. That means, first navigate to the script task, then fetch the extension elements and access child elements of type org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputOutput. Once you have obtained the CamundaInputOutput instance, you can use its accessors to navigate to the script. Have a look at the following example that does the same for the camunda:formData extension:

Cheers,
Thorben

It’ working! Thank you very much your help.