Export (0) Print
Expand All

Settings.refreshAsync method (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Reads all settings persisted in the document and refreshes the content or task pane app's copy of those settings held in memory.

Last modified: June 12, 2014

Available in requirement sets

Settings

Office.context.document.setting.refreshAsync(callback);

callback

Type: object

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

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 refreshAsync method, you can use the properties of the AsyncResult object to return the following information.

Property

Use to...

AsyncResult.value

Access a Settings object with the refreshed values.

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.

This method is useful in Word and PowerPoint coauthoring scenarios when multiple instances of the same app are working against the same document. Because each app is working against an in-memory copy of the settings loaded from the document at the time the user opened it, the settings values used by each user can get out of sync. This can happen whenever an instance of the app calls the Settings.saveAsync method to persist all of that user's settings to the document. Calling the refreshAsync method from the event handler for the settingsChanged event of the app will refresh the settings values for all users.

The refreshAsync method can be called from apps created for Excel, but since it doesn't support coauthoring there is no reason to do so.

In version 1.1 of Office.js, you can create settings in content apps for Access.

function refreshSettings() {
    Office.context.document.settings.refreshAsync(function (asyncResult) {
        write('Settings refreshed 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

Content apps, Task pane apps

Supported clients

Access app for SharePoint, Excel 2013, Excel Online, Excel 2013 SP1, Excel 2013 RT, Word 2013, Word 2013 SP1, Word 2013 RT, PowerPoint 2013, and PowerPoint 2013 SP1, PowerPoint 2013 RT

Library

Office.js

Namespace

Office

Show:
© 2014 Microsoft