I’ve done a small work-around on this,
I load optional data in an API-call before the modeler opens up. I filter this data based on the value of another property of the element. The only downside of this, is that the element needs to be reselected for it to refresh the selectbox-values. At the moment this is the only part i still hope to solve, but for now i’ll take the loss
Here’s an example, this code exists in FormProps.js, it shows the SelectBox-Values based on a Custom Object-attribute that i’ve added in a Start-Event. Instead of the api-call i hardcoded some options.
var datasources = [{
name: "OL_KAND",
object: "Inschrijving"
},
{
name: "OL_FACTUUR",
object: "Inschrijving"
},
{
name: "OL_KOSTEN",
object: "Cursus"
}
];
function filterDatasources(datasources, viperobject) {
var filteredDatasources = [];
datasources.forEach(function(a) {
if (a.object === viperobject) {
filteredDatasources.push(a);
}
});
return filteredDatasources;
};
function getSelectOptions(datasources) {
var selectoptions = [];
datasources.forEach(function(a) {
selectoptions.push({ name: a.name, value: a.name });
});
return selectoptions;
};
var datasourceOptions = []
try {
var viperobject = element.businessObject.Object;
var filterdDatasources = filterDatasources(datasources, viperobject);
datasourceOptions = getSelectOptions(filterdDatasources);
} catch (e) {}
if (!is(element, 'bpmn:UserTask')) {
group.entries.push(entryFactory.comboBox({
id: 'form-field-datasource',
label: 'Datasource',
selectOptions: datasourceOptions,
modelProperty: 'Datasource',
emptyParameter: true,
get: function(element, node) {
var selectedFormField = getSelectedFormField(element, node);
if (selectedFormField) {
return { Datasource: selectedFormField.Datasource };
} else {
return {};
}
},
set: function(element, values, node) {
var selectedFormField = getSelectedFormField(element, node),
formData = getExtensionElements(getBusinessObject(element), 'camunda:FormData')[0],
commands = [];
commands.push(cmdHelper.updateBusinessObject(element, selectedFormField, values));
return commands;
},
hidden: function(element, node) {
return !getSelectedFormField(element, node);
}
}));
}
I know this is an older topic, but i stumbled upon it as i tried to figure out how to refresh the values without needing to reselect the start-event. Thought this might help someone else, and hoping anyone knows how to refresh the element from the setter of another property.
cheers