Export (0) Print
Expand All

RoamingSettings.saveAsync method (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Saves the settings.

Last modified: June 12, 2014

Office.context.roamingSettings.saveAsync(callback);

callback

Type: object

A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. Optional.

When the function you passed to the callback parameter executes, it receives an AsyncResult object that you can access from the callback function's only parameter.

In the callback function passed to the saveAsync method, you can use the properties of the AsyncResult object to return the following information.

Property

Use to...

AsyncResult.value

Always returns undefined because there is no object or data to retrieve.

AsyncResult.status

Determine the success or failure of the operation.

AsyncResult.error

Access an Error object that provides error information if the operation failed.

AsyncResult.asyncContext

Access your user-defined object or value, if you passed one as the asyncContext parameter.

Any settings previously saved by an app are loaded when it is initialized, so during the lifetime of the session you can just use the set and get methods to work with the in-memory copy of the settings property bag. When you want to persist the settings so that they are available the next time the app is used, use the saveAsync method.

function persistSettings() {
    Office.context.roamingSettings.saveAsync(function (asyncResult) {
        write('Settings saved with status: ' + asyncResult.status);
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

App types

Mail apps

Supported clients

Outlook 2013, Outlook Web App, Outlook 2013 SP1, Outlook 2013 RT, and OWA for Devices

Library

Office.js

Namespace

Office

Show:
© 2014 Microsoft