【问题标题】:Office Javascript API: MS Project identify parent task id and sub task idOffice Javascript API:MS Project 识别父任务 ID 和子任务 ID
【发布时间】:2019-12-19 12:49:10
【问题描述】:

我正在构建 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;
}

请看下面的缩进/子任务截图。

现在我需要确定任务是子任务还是缩进任务。识别这一点的最佳方法是什么。任何示例代码都非常有用。请帮忙

【问题讨论】:

    标签: office-js office-addins ms-project


    【解决方案1】:

    使用getTaskFieldAsync 方法获取任务的特定字段值。例如,这将返回任务的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 属性以确定任务是否为摘要。 OutlineChildren 集合以及 OutlineParent 属性可能也很有用。

    有关参考,请参阅this tutorial,了解使用 JavaScript 创建项目加载项。

    【讨论】:

    • 我必须说你节省了我很多时间!!谢谢!!
    猜你喜欢
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 2012-12-06
    • 2011-03-19
    • 1970-01-01
    • 2017-02-10
    • 2021-12-18
    相关资源
    最近更新 更多