Skip to main content

Variables

Some apps need to store and retrieve data (ex: api token). To enable the development of such apps, we provide a variables for apps to set (store) and get (retrieve) variable. Also, variable can be deleted when it is no longer required.

Set variable#

app.variables.set(key, value) — Stores the key, value pair in the variables store. UTF-8 characters are supported. If an entry with the key is already present, then the value will be updated.

Returns — An object with id, name, value, connectedAppId, orgId, sysCreatedBy, sysCreatedTime, sysModifiedBy, sysModifiedTime, visibility.

Example

const result = await window.facilioApp.variables.set('apikey', 'xxxx-xxxx-xxx');// result: { id, name, value, connectedAppId, orgId, ... }

Get variable#

app.variables.get(key) — Retrieves the stored value.

Returns — The stored value directly (not wrapped). Resolves to null or undefined if the key is missing.

Example

const value = await window.facilioApp.variables.get('apikey');// value is "xxxx-xxxx-xxx" or null/undefined if key missing

Delete variable#

app.variables.delete(key) — Deletes the stored variable.

Returnstrue on success.

Example

const success = await window.facilioApp.variables.delete('apikey');// success is true