Application Preferences

Overview

Available since Glue42 Enterprise 3.12

The Application Preferences API is accessible through the glue.prefs object.

See the JavaScript Application Preferences example on GitHub.

Get

To retrieve the stored application preferences for the current application, use the get() method:

const prefs = await glue.prefs.get();

This method resolves with an AppPreferences object with the following properties:

Property Type Description
app string The name of the application with which are associated the stored preferences.
data object The stored application preferences.
lastUpdate Date Timestamp of the last update of the application preferences.

To retrieve the stored application preferences for a specific application, pass an application name to the get() method:

const appName = "clientlist";
const prefs = await glue.prefs.get(appName));

To retrieve the stored application preferences for all applications of the current user, use the getAll() method:

// Resolves with a collection of `AppPreferences` objects.
const prefs = await glue.prefs.getAll();

Set

To set the preferences for the current application, use the set() method:

const prefs = { fontSize: 18 };

await glue.prefs.set(prefs);

The set() method replaces entirely the stored application preferences. All existing properties of the AppPreferences object associated with the app will be removed and replaced with the ones of the argument provided to the set() method.

To set the preferences for a specific application, pass an options object containing the app name as a second argument to the set() method:

const prefs = { fontSize: 18 };
const options = { app: "clientlist" };

await glue.prefs.set(prefs, options);

Update

To update the preferences for the current application, use the udpate() method:

const prefs = { fontSize: 18 };

await glue.prefs.update(prefs);

The update() method modifies only the properties provided in the update object. All other existing properties of the AppPreferences object associated with the app will remain intact.

To update the preferences for a specific application, pass an options object containing the app name as a second argument to the update() method:

const prefs = { fontSize: 18 };
const options = { app: "clientlist" };

await glue.prefs.update(prefs, options);

Clear

To remove the stored application preferences for the current application, use the clear() method:

await glue.prefs.clear();

To remove the stored application preferences for a specific application, pass an application name to the clear() method:

const appName = "clientlist";

await glue.prefs.clear(appName);

To remove the stored application preferences for all applications of the current user, use the clearAll() method:

await glue.prefs.clearAll();

Reference

For a complete list of the available Application Preferences API methods and properties, see the Application Preferences API Reference Documentation.