ProjectDocument.removeHandlerAsync method

Asynchronously removes an event handler for the task selection changed event in a ProjectDocument object.

Hosts: Project
Available in Requirement set Selection
Added in 1.0
Office.context.document.removeHandlerAsync(eventType[, options][, callback]);


Name Type Description Support notes
eventType EventType The type of event to remove, as an EventType constant or its corresponding text value. Required. See eventType value.
options object Specifies any of the following optional parameters.
asyncContext array, boolean, null, number, object, string, or undefined A user-defined item of any type that is returned in the AsyncResult object without being altered.
callback object A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.

eventType value

The following table shows valid eventType arguments for a ProjectDocument object.

Enumeration Text value
Office.EventType.ResourceSelectionChanged resourceSelectionChanged
Office.EventType.TaskSelectionChanged taskSelectionChanged
Office.EventType.ViewSelectionChanged viewSelectionChanged

Callback value

When the callback function executes, it receives an AsyncResult object that you can access from the parameter in the callback function.

For the removeHandlerAsync method, the returned AsyncResult object contains the following properties.

Name Description
asyncContext The data passed in the optional asyncContext parameter, if the parameter was used.
error Information about the error, if the status property equals failed.
status The succeeded or failed status of the asynchronous call.
value removeHandlerAsync always returns undefined.


The following code example uses addHandlerAsync to add an event handler for the ResourceSelectionChanged event and removeHandlerAsync to remove the handler.

When a resource is selected in a resource view, the handler displays the resource GUID. When the handler is removed, the GUID is not displayed.

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

<input id="remove-handler" type="button" value="Remove handler" /><br />
<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, add-in-specific code can run.

    // Remove the event handler.
    function removeEventHandler() {
            asyncContext:'The handler is removed.'},
            function (result) {
                if (result.status === Office.AsyncResultStatus.Failed) {
                else {
                    $('#remove-handler').attr('disabled', 'disabled');

    // Get the GUID of the currently selected resource and display it in the add-in.
    function getResourceGuid() {
            function (result) {
                if (result.status === Office.AsyncResultStatus.Failed) {
                else {
                    $('#message').html('Resource GUID: ' + result.value);

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

Support details

A capital Y in the following matrix indicates that this method is supported in the corresponding Office host application. An empty cell indicates that the Office host application doesn't support this method.

For more information about Office host application and server requirements, see Requirements for running Office Add-ins.

Office for Windows desktop Office Online (in browser)
Project Y
Available in requirement sets Selection
Minimum permission level ReadWriteDocument
Add-in types Task pane
Library Office.js
Namespace Office

Support history

Version Changes
1.0 Introduced

See also