The issue creation steps are like this.
- I drag and drop an activity task. (Contains custom input tab). In the Input tab, there is a dropdown i.e.
SelectBox
. I select a value from the dropdown.
- Then I select other activity or in caumnda:Process area.
3)Then I came back again on the activity task. Then go to the input tab, the dropdown value must visible that I had selected previously.
How I can set value dropdown or entryFactory.selectBox
programmatically that I had selected before?
My Code,
export default function(group, element, translate, dropdownOptions, ddName, _id, bpmnFactory) {
if (is(element, 'bpmn:Activity')) {
var bo = getBusinessObject(element);
var attributes = bo.$attrs;
var values = attributes[_id];
if(window.dropDownValue !== undefined){
dropdownOptions = window.dropDownValue;
}
var dropdownBox = entryFactory.selectBox(translate, {
id: _id,
label: ddName,
emptyParameter: false,
selectOptions: dropdownOptions,
modelProperty: _id,
get: function(element, node) {
return bo;
},
set: function setValue(element, values, node) {
var b_obj = getBusinessObject(element);
var selectedValues = {};
selectedValues = values;
prop[_id] = selectedValues[_id];
var selectedName = dropdownOptions[parseInt(prop[_id])].name;
var bo = cmdHelper.updateBusinessObject(element, b_obj, selectedValues);
//Code here to reflect selected value in xml.
return bo;
}
})
group.entries.push(dropdownBox);
}
}
So to understand your use case correctly, you want something like a global value that should be shown for any element? Or should it persist for a specific element?
The properties panel is created in a way it always consumes and shows the underlying BPMN 2.0 XML. So when you set a property to a specific element, it should show up, also when you switch to another one and switch back again. The XML is the single source of truth.
I used global variable just for loading dropdown values dynamically from outside minified JS.
I sharing my issue in visual context here,
I set my selected value from dropdown into the input parameter,
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="Process_1" isExecutable="true">
<bpmn2:startEvent id="StartEvent_1" />
<bpmn2:userTask id="APS" name="Appointment Scheduled">
<bpmn2:extensionElements>
<camunda:executionListener delegateExpression="#{mIDUpdaterService}" event="start" />
<camunda:executionListener delegateExpression="#{mIDUpdaterService}" event="end" />
<camunda:inputOutput>
<camunda:inputParameter name="Connector_Name">Xyz1</camunda:inputParameter>
</camunda:inputOutput>
</bpmn2:extensionElements>
</bpmn2:userTask>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="412" y="240" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0mafd0t_di" bpmnElement="APS">
<dc:Bounds x="500" y="218" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
If XML is the only source of truth then there must be something missing apart from it.
Can you guide me how can I resolve this issue?
Thanks for providing some more details! It helps to better understand your use case. Having a quick look at your code I wonder about the getter of your select box
get: function(element, node) {
return bo;
}
The selectBox
getter is expecting to return the value for the defined modelProperty, so something like
return {
_id: bo.get('_id') // or how the property is set inside the XML
};
That would be a good starting point for a root cause search. If this doesn’t help I think the best would be to share your properties panel extension inside a CodeSandbox so we can better investigate it.