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

JavaScript API for Office v1.1

Asynchronously gets the text value of the data that is contained in the current selection of one or more cells in the Gantt Chart view.

Last modified: August 25, 2014

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


Type: CoercionType

The type of data structure to return. Required.

Project 2013 supports only "text" or Office.CoercionType.Text for the coercionType argument.


One or more of the following optional parameters:


Type: ValueFormat

The formatting to use for number or date values. Optional.

Project 2013 ignores this parameter and internally sets it to unformatted.


Type: FilterType

Specifies whether to include only visible data or all data. Optional.

Note Note

Project 2013 ignores this parameter and internally sets it to all.


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.

For example, you can pass the asyncContext argument by using the format {asyncContext: 'Some text'} or {asyncContext: <object>}.


Type: function

A function that is invoked when the method call returns, where the only parameter is of type AsyncResult. Optional.

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

For the getSelectedDataAsync method, the returned AsyncResult object contains the following properties:




The data that was passed in the optional asyncContext parameter, if the parameter was used.


Information about the error, if the status property equals failed.


The succeeded or failed status of the asynchronous call.


The text value of the selected cells.

The ProjectDocument.getSelectedDataAsync method overrides the Document.getSelectedDataAsync method and returns the text value of data that is selected in one or more cells in the Gantt Chart view. ProjectDocument.getSelectedDataAsync supports only a text format as the CoercionType—it does not support matrix, table, or other formats.

The following code example gets the values of the selected cells. It uses the optional asyncContext parameter to pass some text to the callback function.

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

<input id="get-info" type="button" value="Get info" /><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, app-specific code can run.

    // Get the text from the selected cells in the document, and display it in the app.
    function getSelectedText() {
            {asyncContext: 'Some related info'},
            function (result) {
                if (result.status === Office.AsyncResultStatus.Failed) {
                else {
                    var output = String.format(
                        'Selected text: {0}<br/>Passed info: {1}',
                        result.value, result.asyncContext);

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

Supported clients

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


Office.js, Project-15.js



© 2014 Microsoft