getVar
getVar
Reads the current value of a form variable (Form Var) predefined in the LucyStudio designer, from a form script.
Parameters
localVarName(string): A variable name predefined in the LucyStudio form settings
Returns: any — the variable's current value, or null for an undefined variable name
Description
$form.getVar reads the value of a variable predefined per form in the LucyStudio designer. Internally it calls LucyVarMngr.getVarValue(_mapFormVar, localVarName).
The variable is valid only for the current form instance; you can't reach variables belonging to another form instance.
warning
The variable name must be predefined in the LucyStudio designer. An undefined name returns null.
$form vs $app vs $page
$form.getVar | $app.getVar | $page.getVar | |
|---|---|---|---|
| Scope | Current form instance | Shared app-wide | ❌ Not supported |
| Where it's predefined | LucyStudio form settings | LucyStudio app settings | — |
| Lifetime | Destroyed when the form closes | Kept while the app runs | — |
| Access from another form | ❌ No | ✅ Yes | — |
Example
// 폼 변수 읽기
var count = $form.getVar("count");
$log.i("현재 카운트:", count);
var user = $form.getVar("selectedUser");
if (user !== null) {
$log.i("선택된 사용자:", user.name);
} else {
$log.i("선택된 사용자 없음");
}
Related
$form.setVar(localVarName, data)— sets a form variable$form.clearVar(localVarName)— resets a form variable to its initial value$app.getVar(appVarName)— reads an app-wide variable$form.getSharedData(key)— reads in-memory data under an arbitrary key (no predefinition needed)