Office Javascript API:MS Project标识父任务ID和子任务ID [英] Office Javascript API: MS Project identify parent task id and sub task id
问题描述
我正在构建MS Project Web加载项.使用下面的函数作为其他函数的基础,我可以检索task, id and resource name
.
// Get the maximum task index, and then get the task GUIDs.
async getTasks(guids: string[]): Promise<any[]> {
return await Promise.all(
guids.map(async guid => await this.getTask(guid))
);
}
async getTaskGuids(maxIndex: number): Promise<string[]> {
const guids = [];
for (let i = 0; i <= maxIndex; i++) {
guids.push(await this.getTaskGuid(i));
}
return guids;
}
请参见下面的屏幕截图,其中包含缩进/子任务.
现在,我需要确定任务是子任务还是缩进任务.识别此问题的最佳方法是什么.任何示例代码都非常有帮助.请帮助
使用getTaskFieldAsync
方法获取任务的特定字段值.例如,它返回概述级别任务(例如1、2、3等):
_projDoc.getTaskFieldAsync(taskGuid, Office.ProjectTaskFields.OutlineLevel,
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
text.value = text.value + "Outline Level: "
+ asyncResult.value.fieldValue + "\n";
}
else {
logMethodError("getTaskFieldAsync", asyncResult.error.name,
asyncResult.error.message);
}
}
);
另请参阅任务摘要属性,用于确定任务是否为摘要. OutlineChildren 集合也可能有用以及 OutlineParent 属性.>
有关参考,请参见 解决方案
Use the getTaskFieldAsync
method to get specific field values for a task. For example this returns the Outline Level of a task (e.g. 1, 2, 3, etc.):
_projDoc.getTaskFieldAsync(taskGuid, Office.ProjectTaskFields.OutlineLevel,
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
text.value = text.value + "Outline Level: "
+ asyncResult.value.fieldValue + "\n";
}
else {
logMethodError("getTaskFieldAsync", asyncResult.error.name,
asyncResult.error.message);
}
}
);
Also see the task Summary property to determine if a task is a summary or not. The OutlineChildren collection might also be useful as well as the OutlineParent property.
For reference, see this tutorial on creating a Project add-in using JavaScript.
这篇关于Office Javascript API:MS Project标识父任务ID和子任务ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!