It set the value in the UI also, the properties releated to the selected template is populating. But, the XML is not having the properties (extensionElements and camunda:inputOutput node). I’m getting as below.
Thank you @philippfromme. It is working fine. Based on this, the item from element template is choosing and Custom fields related to the selected item is listing as below
But when download the XML file. It is not having the custom field nodes inside <serviceTask>. The solution is not triggering the PropertiesPanel.prototype._bindListeners method internally.
I have the same problem. You don’t need to trigger PropertiesPanel.prototype._bindListeners, but the function handleChange(event) method. You can achieve this with the following rows:
var event = document.createEvent('Event');
event.initEvent('change', true, true);
document.getElementById('camunda-elementTemplate-chooser-select').dispatchEvent(event);
Unfortunately this is still not enough to persist the custom fields into bpmn. Something else is responsible for this. You can see this if you debug the UpdatePropertiesHandler.prototype.execute method.
In our case it will be called only once, but if you manually select a value from the selectbox it will be called more than one time and you can also see the custom properties in one of the objects.
I hope I could help and I hope someone can help us to completely solve our problems. How to persist the custom fields in the upper scenario?
Thank you!
I solved it!
Don’t use updateProperties, just these lines are needed, which will set the neessary option and then trigger a change event on the select element. This way your custom fields will be saved.
I suppose to set the elementtemplate value dynamically. That was implemented by setting the value in the businessObject. Code as follow.
It set the value in the PropertyPanel (UI) but the same is not reflected in the downloaded XML. Please refer the below gif image for the same. When user interaction happened with the element custom fields, then only the XML is updated with <extensionElements>.
How to get the <extensionElements> in XML on dynamic set of element template.
Using elementShape.businessObject.set( “camunda:modelerTemplate”, this.selectedTaskId ); will ONLY set the camunda:modelerTemplate property. It will NOT set all the properties that are defined in your template.