Skip to main content

setVar

Sets a value on an App Var predefined at the app level in the LucyStudio designer. The value you set is shared across the entire app.

Parameters

  • appVarName (string): Name of a variable predefined in the LucyStudio app settings
  • data (any): Value to set (string, number, boolean, object, and so on)

Returns

None (void)

Description

$app.setVar stores a value in a variable predefined at the app level in the LucyStudio designer. Internally it calls LucyVarMngr.setVarValue(appVarMap, appVarName, data).

Because the value is shared across the whole app, you can read and write it from any Form or Page using the same variable name. It persists for as long as the app is running.

⚠️ The variable name must be predefined in the LucyStudio designer. An undefined variable name does nothing. Unlike setSharedData / setStoreData, you can't use an arbitrary key.

⚠️ Add the LucyStudio Variables settings screen here, or link to it

$app vs $form vs $page comparison

Item$app.setVar$form.setVar
ScopeShared app-wideCurrent Form instance
Where it's predefinedLucyStudio app settingsLucyStudio Form settings
LifecyclePersists while the app runsDestroyed when the Form closes
clearVar reset targetThe default value set at declarationThe default value set at declaration
Access from another Form✅ Yes❌ No

For a variable used only inside a single Form, use $form.setVar.

Example

// When the "loginUserId" and "theme" variables are predefined in the LucyStudio app settings
$app.setVar("loginUserId", "user_001");
$app.setVar("theme", "dark");
$app.setVar("cartItems", [{ id: 1, qty: 2 }, { id: 3, qty: 1 }]);

// Read from another form or page
var userId = $app.getVar("loginUserId");
$log.i("로그인 사용자:", userId);
  • $app.getVar(appVarName) — Read an App Var
  • $app.clearVar(appVarName) — Reset an App Var to its initial value
  • $form.setVar(localVarName, data) — Set a Form-level variable (valid only in that Form)
  • $app.setSharedData(key, data) — Store in-memory data under an arbitrary key (no predefinition needed)