Have you found a solution to this? I am having the same issue, I see the camunda variable’s original value points to the correct value but it doesn’t select the right option in the dropdown and rather assigns it a new value (the first option in the dropdown).
Hi @some-camunda-user,
I actually resorted to a custom solution adding code to the form-load and fetching phases.
Hope you’ll understand this:
<cam-script> ...
var varManager = camForm.variableManager;
// ---------------------------------------------------------------------------
// WOKAROUND SELECT - Management of select fields
// ---------------------------------------------------------------------------
var camSelectList = {};
$("select").each(function() {
var camWA = $(this).attr("cam-var-workaround");
if (camWA) {
camSelectList[camWA] = $(this)
}
});
camForm.on('form-loaded', function() {
// fetching selects
for (var camWA in camSelectList) {
varManager.fetchVariable(camWA);
}
});
camForm.on('variables-fetched', function() {
// Setting the value on selects
for (var camWA in camSelectList) {
var select = camSelectList[camWA]
var v = varManager.variableValue(camWA)
// If variable does not exist in execution it must be re-created as we desire (to null)
if (!v) {
// Create the variable in the correct way
varManager.destroyVariable(camWA)
varManager.createVariable({
name: camWA,
type: 'String',
value: null,
isDirty: true
});
varManager.variableValue(camWA, "")
}
select.val(varManager.variableValue(camWA));
}
});