ProjectDocument object (JavaScript API for Office v1.0)

JavaScript API for Office v1.0

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

Last modified: June 12, 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.

You do not directly call or instantiate the ProjectDocument object in your script. The Office.js file uses the ProjectDocument constructor in the Project-15.js file to extend the Office.context.document object. When an app task pane is active in Project Professional 2013, the document is the active project. To access members of the ProjectDocument object, you can initialize the Office object, and then create an instance variable that contains the Office.context.document object.

The following example initializes an instance variable named _projDoc to access members of the ProjectDocument object. The url property is defined in the Office.js file. Because the extended document object implements the ProjectDocument object, the url property gets the URL of the active project.

In the following code, the textBox object is a reference to a textarea control in an HTML file, for example: <textarea id="textBox" rows="6" cols="25"></textarea>

var _projDoc;

Office.initialize = function (reason) {
   // Checks for the DOM to load using the jQuery ready function.
    $(document).ready(function () {
    // After the DOM is loaded, app-specific code can run.
    _projDoc = Office.context.document; 
    });
}

function showProjectUrl() {
    textbox.value = 'The active project is: ' + _projDoc.url;
}

Supported clients

Project Standard 2013 and Project Professional 2013

Libraries

Office.js, Project-15.js

Namespace

Office

Show:
© 2014 Microsoft