ProjectDocument object (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

An abstract class that represents the project document (the active project) with which the app for Office interacts.

Last modified: September 18, 2014

Office.context.document

Methods

Name

Description

addHandlerAsync method

Asynchronously adds an event handler for an event in a ProjectDocument object.

getProjectFieldAsync method

Asynchronously gets the value of the specified field in the active project.

getResourceFieldAsync method

Asynchronously gets the value of the specified field for the specified resource.

getSelectedDataAsync method

Asynchronously gets the data that is contained in the current selection of one or more cells in the Gantt chart.

getSelectedResourceAsync method

Asynchronously gets the GUID of the selected resource.

getSelectedTaskAsync method

Asynchronously gets the GUID of the selected task.

getSelectedViewAsync method

Asynchronously gets the view type and name of the active view.

getTaskAsync method

Asynchronously gets the task name, the resources that are assigned to the task, and the ID of the task in the synchronized SharePoint task list.

getTaskFieldAsync method

Asynchronously gets the value of the specified field for the specified task.

getWSSUrlAsync method

Asynchronously gets the URL of the synchronized SharePoint task list.

removeHandlerAsync method

Asynchronously removes an event handler for an event in a ProjectDocument object.

Events

Name

Description

ResourceSelectionChanged event

Occurs when the resource selection changes in the active project.

TaskSelectionChanged event

Occurs when the task selection changes in the active project.

ViewSelectionChanged event

Occurs when the active view changes in the active project.

Do not directly call or instantiate the ProjectDocument object in your script.

The following example initializes the app and then gets properties of the Document object that are available in the context of a Project document. A Project document is the opened, active project. To access members of the ProjectDocument object, use the Office.context.document object as shown in the code examples for ProjectDocument methods and events.

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 () {

            // Get information about the document.
            showDocumentProperties();
        });
    };

    // Get the document mode and the URL of the active project.
    function showDocumentProperties() {
        var output = String.format(
            'The document mode is {0}.<br/>The URL of the active project is {1}.',
            Office.context.document.mode,
            Office.context.document.url);
        $('#message').html(output);
    }
})();

Supported clients

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

Libraries

Office.js, Project-15.js

Namespace

Office

Show:
© 2014 Microsoft