Skip to content

Set Local Variable

This command lets you update a new value to local variables.

Parameters

ParameterTypeDescription
variableIdStringUnique Id of the variable.
valueString or Number or BooleanNew value to the variable.
payloadObjectObject with keys as variableId and its values in respective data type.

Syntax

Follow the syntax to update a single variable:

kf.app.page.setVariable(variableId, value);

Follow the syntax to update multiple variables:

kf.app.page.setVariable({
variableId: "new value",
variableId2: 1,
});

Example

Consider you are an HR representative who wants to save a new email address for an employee. Before saving, the app needs to perform a validation check to see if the email already exists in the system. In this scenario, a local variable can be set to store the new email address entered by the user during the time the validation process happens. Once the validation is complete and the employee’s new information is saved, the local variable can be released.