Version

Persisting SharePlus Mobile Workspaces Settings

Overview

The WebDashboard.Settings.save and WebDashboard.Settings.load JavaScript API methods allow you to manage dynamic settings within your mobile workspace. Settings can be stored in SharePlus under a specific key, making them persistent, and later they can be loaded again when the mobile workspace is reloaded.

Code

In the code snippet below, you use the custom JavaScript function saveSettings to:

  • Create the settings JSON Object.

  • Specify the mobile workspace’s key.

  • Call the WebDashboard.Settings.save API from the bridge to store the settings under a unique key.

var stringValue = ‘string content‘;
var numericValue = 15;

function saveSettings() {
    var settings = {};
    settings['stringValue’] = stringValue;
    settings['numericValue’] = numericValue;

    var key = 'MobileWorkspaceOne'; // unique key, identifies specific settings to be stored
    SPlus.WebDashboard.Settings.save(settings, key, function () {

    }, function (responseError) {
        SPlus.Utility.showMessage('Save Settings Error', responseError['error#displayValue']);
    });
}

The callback functions shown above for WebDashboard.Settings.save are:

  • A success callback function, which receives no parameters and may not be implemented as shown above.

  • An error callback function, which receives a JavaScript object with the error description.

Custom mobile workspaces settings stored in SharePlus can be loaded later. In the code snippet below, you use the custom JavaScript function loadSettings to call the WebDashboard.Settings.load API from the bridge. The API function loads previously stored settings identifying them through a unique key.

function loadSettings() {
    var key = 'MobileWorkspaceOne'; // Key used to identify the specific settings to be loaded

    SPlus.WebDashboard.Settings.load(key, function (settings) {
        if (settings) {
            stringValue = settings['stringValue'];
            numericValue = settings['numericValue'];
        }
    }, function (responseError) {
        SPlus.Utility.showMessage('Load Settings Error', responseError['error#displayValue']);
    });
}

The callback functions shown above for WebDashboard.Settings.load are:

  • A success callback function, which receives a JSON object with the configuration settings loaded for a specific SharePlus Mobile Workspace.

  • An error callback function, which receives a JavaScript object with the error description.