0

我正在尝试制作一个 Office 任务窗格应用程序,它可以访问资源日历异常,并将它们显示给用户。

我设法访问了资源,我可以获得很多字段,但不能获得日历例外。看起来,它们直接存储在其他地方,而不是 Resource 对象中。

一些代码片段:

//First, I get the ID of a resource, that is clicked and store it in resourceGuid
function getSelectedResourceAsync() {
    Office.context.document.getSelectedResourceAsync(function (asyncResult) {
        if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
            resourceGuid = asyncResult.value;
        }
    });
}

然后我使用此 ID 来获取选定的资源字段,例如名称、成本、工作等,并将它们显示在 HTML 任务窗格上的文本字段中。例子 :

function getResourceFields() {
    text.value = "";
    //I get the name of the resource here, and have it displayed in the textfield
    Office.context.document.getResourceFieldAsync(resourceGuid, Office.ProjectResourceFields.Name,
        function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
                text.value = text.value + "Resource name: " + asyncResult.value.fieldValue + "\n";
            }
        }
    );

//After this, I'm getting the ResourceCalendarGuid, which is a promising name for 
//the resources calendar, but I'm stuck with it. I didn't find a way to 
//actually access the resources calendar.

Office.context.document.getResourceFieldAsync(resourceGuid, Office.ProjectResourceFields.ResourceCalendarGUID,
        function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
                calendarGuid = asyncResult.value.fieldValue;
            }
        }
    );
}

我想使用此 ResourceCalendarGUID 访问资源唯一日历,其中存储了异常,并且我想通过 html 任务窗格上的文本字段向最终用户显示这些异常。

感谢您的时间!

4

0 回答 0