ProjectDocument.getSelectedDataAsync method (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

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

Last modified: February 26, 2014

Office.context.document.getSelectedDataAsync(coercionType [, options], callback);


Type: CoercionType

The type of data structure to return. Required.

Note Note

Project 2013 supports only a CoercionType value of "text" or Office.CoercionType.Text (see the Office.CoercionType enumeration).


Type: object

Specifies the following optional parameters.


Type: ValueFormat

Note Note

The valueFormat parameter is internally set to "unformatted"; Project 2013 ignores this parameter.

Specifies whether to return the result with its number or date values formatted or unformatted. Optional.


Type: FilterType

Specifies whether to apply filtering when the data is retrieved. Optional.

Note Note

The filterType parameter is internally set to "all". Word 2013 and Project 2013 ignore this parameter.


Type: 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. Optional.


Type: object

A function with a parameter of type AsyncResult, which is invoked when the callback returns. Optional.

When the function that you pass to the callback parameter executes, it receives an AsyncResult object that you can access from the parameter in the callback function. Use the AsyncResult.value property to access the values in the current selection. The values are returned in the "text" format that is specified by the coercionType parameter.

To determine the success or failure of the operation, use the AsyncResult.status property. If the operation fails, use the AsyncResult.error property to access an Error object that provides information about the error.

The ProjectDocument.getSelectedDataAsync method overrides the Document.getSelectedDataAsync method, to return the text value of data that is selected in one or more cells in the Project Gantt chart. The ProjectDocument.getSelectedDataAsync method supports only "text" for the CoercionType parameter; it does not support "matrix", "table", or other values.

In the following example, the showSelectedText method gets the unformatted text value of all selected cells in the current grid view of the active project, and displays the value or the error information.

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;

// The initialize function is required for all apps.
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 showSelectedText() {
        { asyncContext: "any object" },
        function (asyncResult) {
            if (asyncResult.status === Office.AsyncResultStatus.Failed) {
                var error = asyncResult.error;
                textBox.value = + ': ' + error.message;
            } else {
                var textValue = asyncResult.value;
                textBox.value = 'Selected data:\n' + textValue 
                                + '\nPassthrough data:\n' + asyncResult.asyncContext;

Supported clients

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


Office.js, Project-15.js



© 2014 Microsoft