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
方法获取任务的特定字段值。例如这个 returns 任务的 Outline Level(例如 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);
}
}
);
另见任务Summary property to determine if a task is a summary or not. The OutlineChildren collection might also be useful as well as the OutlineParent属性.
有关参考,请参阅 this tutorial 使用 JavaScript 创建项目加载项。
我正在构建 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
方法获取任务的特定字段值。例如这个 returns 任务的 Outline Level(例如 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);
}
}
);
另见任务Summary property to determine if a task is a summary or not. The OutlineChildren collection might also be useful as well as the OutlineParent属性.
有关参考,请参阅 this tutorial 使用 JavaScript 创建项目加载项。