Item.loadCustomPropertiesAsync method (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Asynchronously loads custom properties that are specific to the item and a app for Office.

Last modified: November 24, 2014

Applicable Outlook modes

Compose or read

Available in requirement sets

Mailbox

Office.context.mailbox.item.loadCustomPropertiesAsync(callback,userContext);

callback

The method to call when the asynchronous load is complete. Required.

userContext

Any state data that is passed to the asynchronous method. Optional.

You must call the loadCustomPropertiesAsync method before using the CustomProperties object methods. Custom properties are saved on the Exchange Server 2013 as a property bag for an item. When the asynchronous call finishes, the method specified in the callback parameter is called by using one parameter, asyncResult, which contains the property bag in its value property. You can use the optional userContext parameter to pass any state information to the callback function. The callback function can then process the custom properties, such as setting a value and saving the property back to the Exchange server.

In this article, "Outlook" refers to Outlook for Windows, Outlook for Mac, Outlook RT, OWA for Devices (OWA for Android phones, OWA for iPad, OWA for iPhone), and Outlook Web App. "Outlook rich clients" refers to Outlook for Windows, Outlook for Mac and Outlook RT. At this point, Outlook for Mac supports JavaScript API for Office in only Outlook read mode, and can activate mail apps that reference office.js version 1.0 or 1.1 and use apps for Office schema version 1.0.

The following code example shows how to use the loadCustomPropertiesAsync method to asynchronously load custom properties that are specific to the current item in Microsoft Outlook. The example also shows how to use the CustomProperties.saveAsync method to save these properties back to the Exchange Server. After loading the custom properties, the code sample uses the CustomProperties.get method to read the custom property myProp, the CustomProperties.set method to write the custom property otherProp, and then finally calls the saveAsync method to save the custom properties.

// The initialize function is required for all apps.
Office.initialize = function () {
    // Checks for the DOM to load using the jQuery ready function.
    $(document).ready(function () {
    // After the DOM is loaded, app-specific code can run.
    var item = Office.context.mailbox.item;
    item.loadCustomPropertiesAsync(customPropsCallback);
    });
}




function customPropsCallback(asyncResult) {
    var customProps = asyncResult.value;
    var myProp = customProps.get("myProp");

    customProps.set("otherProp", "value");
    customProps.saveAsync(saveCallback);
}

function saveCallback(asyncResult) {
}

App types

Mail app

Supported clients

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

Library

Office.js

Namespace

Office

Show:
© 2014 Microsoft