ProjectDocument.ResourceSelectionChanged event (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Occurs when the resource selection changes in the active project.

Last modified: August 26, 2014

Office.EventType.ResourceSelectionChanged

ResourceSelectionChanged is an EventType enumeration constant that can be used in the ProjectDocument.addHandlerAsync and ProjectDocument.removeHandlerAsync methods to add or remove a handler for the event.

The following code example adds a handler for the ResourceSelectionChanged event. When the resource selection changes in the document, it gets the GUID of the selected resource.

The example assumes your app has a reference to the jQuery library and that the following page control is defined in the content div in the page body:

<span id="message"></span>
(function () {
    "use strict";

    // The initialize function must be run each time a new page is loaded.
    Office.initialize = function (reason) {
        $(document).ready(function () {

            // After the DOM is loaded, app-specific code can run.
            Office.context.document.addHandlerAsync(
                Office.EventType.ResourceSelectionChanged,
                getResourceGuid);
        });
    };

    // Get the GUID of the selected resource and display it in the app.
    function getResourceGuid() {
        Office.context.document.getSelectedResourceAsync(
            function (result) {
                if (result.status === Office.AsyncResultStatus.Failed) {
                    onError(result.error);
                }
                else {
                    $('#message').html(result.value);
                }
            }
        );
    }

    function onError(error) {
        $('#message').html(error.name + ' ' + error.code + ': ' + error.message);
    }
})();

For a complete code sample that shows how to use a ResourceSelectionChanged event handler in a Project app, see How to: Create your first task pane app for Project 2013 by using a text editor.

Supported clients

Project Standard 2013, Project Professional 2013, and Project 2013 SP1

Libraries

Office.js, Project-15.js

Namespace

Office

Show:
© 2014 Microsoft