Skip to main content
Version: 1.7.3.X

Form Variables

Read current variable values and update writable fields from a custom extension. Use the variable or field's logical name without double curly braces.

const control = globalThis.MaptaskrControlManager.getControl(controlId);

setVariableValue​

Set the value of a field on the current host form or page.

const updated = control.setVariableValue('firstname', 'John');

if (!updated) {
console.warn('The field could not be updated.');
}
ParameterTypeRequiredDescription
keystringYesLogical name of the field on the current form or page.
newValuestringYesNew value. Maptaskr converts the string according to the target field type before applying the value.

Returns true when the host field is found and updated. Returns false when the field is unavailable or the value cannot be applied. Variables supplied through additional parameters or other injected context are read-only and return false.

getVariableValue​

Get the current value of one host field or injected variable.

const accountName = control.getVariableValue('name');

if (accountName !== undefined) {
console.log(accountName);
}
ParameterTypeRequiredDescription
keystringYesLogical name of the field or injected variable.

Returns the current value as a string, number, boolean, lookup value, or null. Returns undefined when the variable is unavailable. A null result is a valid value for an empty field.

getAllVariableValues​

Get the current values for all known host fields and injected variables.

const variables = control.getAllVariableValues();

console.log(variables.firstname);
console.log(variables.appid);

This method has no parameters. It returns an object keyed by logical variable name. Variables that are no longer available are omitted, and an empty object is returned when no variables are known.