Input Select in Embedded Forms won't assign the value from variable

Camunda embedded form is not showing up SELECT input fields in forms with pre-populated values from execution.

Script(or any setting during the process before calling the user Task):

execution.setVariable(“team”, “Inter”)

In the form i tried the followings:
HTML version 1 (simple options):

	<select cam-variable-name="team" cam-variable-type="String">
 		<option>Milan</option>
                 <option>Inter</option>
 	</select>

HTML version 2 (values and descr.):

1 Like

Hi @Mizar01,

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));
	}
});

Any select input must be written like this:

<select  cam-var-workaround='the_execution_variable_name'>