Export (0) Print
Expand All

AsyncResult.asyncContext property (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Gets the user-defined item passed to the optional asyncContext parameter of the invoked method in the same state as it was passed in.

Last modified: June 12, 2014

var myContext = asynchResult.asyncContext;

Returns the user-defined item (which can be of any JavaScript type: String, Number, Boolean, Object, Array, Null, or Undefined) passed to the optional asyncContext parameter of the invoked method. Returns Undefined, if you didn't pass anything to the asyncContext parameter.

function getDataWithContext() {
    var format = "Your data: ";
    Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, { asyncContext: format }, showDataWithContext);
}

 function showDataWithContext(asyncResult) {
    write(asyncResult.asyncContext + asyncResult.value);
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

App types

Content app, Mail app, Task pane app

Supported clients

Access app for SharePoint, Excel 2013, Excel 2013 SP1, Excel 2013 RT, Excel Online, Word 2013, Word 2013 SP1, Word 2013 RT, Outlook 2013, Outlook 2013 SP1, Outlook 2013 RT, Outlook Web App, OWA for Devices, PowerPoint 2013, PowerPoint 2013 SP1, PowerPoint 2013 RT, Project 2013, and Project 2013 SP1

Library

Office.js

Namespace

Office

Show:
© 2014 Microsoft