I wanted to add script and execution listener to a task using the bpmn model API after creating the Bpmn file through the UI by using bpm-js .
What is your question? Have you tried anything yet?
I am trying to explore the API.I want to add script in execution listener and also expressions . And can you also explain what are attributes in case of a task like there is a function to set a attribute.what does the function expects.
You can find resources on the model API here:
- https://docs.camunda.org/manual/7.8/user-guide/model-api/bpmn-model-api/
- https://github.com/camunda/camunda-bpm-examples
The first link and its section Create a Model show how to add elements to a model and can be easily adapted to work with an existing model. If you have question on specific methods, please link to the Javadoc so that we know what methods you are talking about.
I also encourage you to simply try things out. Via Bpmn.writeModelToStream(System.out, modelInstance);
you can always print the XML of the current model state and check the effects a certain method had on the XML.
Cheers,
Thorben
Like servicetask.setAttributesValueNs(namespaces tu,attribute name,xmlValue)
So here the name space for me would be camunda namespace.attribute name would be camunda:tasklistener in this case what would be the XML value.
The task listener requires the event type ,expression and has child type camunda:script .I would like to attach a script to it.How can it be done .
In XML, we have attributes and elements: https://www.w3schools.com/xml/xml_dtd_el_vs_attr.asp
The method you found sets an attribute value, however a task listener is an element: https://docs.camunda.org/manual/7.8/user-guide/process-engine/delegation-code/#task-listener
So you will have to use methods that add elements. The examples here show how to add elements with model API: https://docs.camunda.org/manual/7.8/user-guide/model-api/bpmn-model-api/create-a-model/
Make sure to get the XML structure right, i.e. first add a child element of type org.camunda.bpm.model.bpmn.instance.ExtensionElements
, then add a child element to that of type org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener
. Use the setter methods of CamundaTaskListener
to define the listener’s attributes/values like a script etc.
Good luck!
Is there a way to do it via python. Not using JAVA ?