我正在尝试创建一个可以访问资源日历例外的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任务窗格上的文本字段向最终用户显示这些异常。
感谢您的时间!