I did try using the Office.context.document.getSelectedDataAsync(), but I need to click in the row to get the data from the task.
I need to get all tasks without clicking using Javascript inside the Add-in Project.
I did try using the Office.context.document.getSelectedDataAsync(), but I need to click in the row to get the data from the task.
I need to get all tasks without clicking using Javascript inside the Add-in Project.
You can find all the available methods described for the Office.Document class in MSDN. The getTaskAsync
or getTaskByIndexAsync
method allows getting the Task Name, WSS Task Id, and ResourceNames for given taskId
:
// Get data for the specified task.
function getTaskAsync() {
if (taskGuid != undefined) {
_projDoc.getTaskAsync(
taskGuid,
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
logMethodError("getTaskAsync", asyncResult.error.name,
asyncResult.error.message);
} else {
var taskInfo = asyncResult.value;
var taskOutput = "Task name: " + taskInfo.taskName +
"\nGUID: " + taskGuid +
"\nWSS Id: " + taskInfo.wssTaskId +
"\nResourceNames: " + taskInfo.resourceNames;
text.value = taskOutput;
}
}
);
} else {
text.value = 'Task GUID not valid:\n' + taskGuid;
}
}
See Create your first task pane add-in for Microsoft Project by using a text editor for more information.