Skip to content

Set Local Variable

This method lets you to update a new value to local variables

Parameters

ParameterstypeDescription
variableIdStringUnique Id of variable
valueString or Number or BooleanNew value to 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 scenario

Consider you have fetched employee details such as name, age & address during the page’s onload event. You can set local variables for all these fields and use them on different components inside the page, such as displaying labels or cards.