问题描述
我有一个Outlook加载项(Office 365 Web),当我的任务窗格打开时,我需要获取事件重复发生。 我在“ Office.onReady”方法中使用Office.context.mailBox.item.recurrence.getAsync(),但是如果在打开任务窗格时更改了重复值,则该重复值是上一个。
测试A :重复和任务窗格打开/关闭
-
创建“新事件”
-
更改重复周期(“每日”)
-
打开任务窗格,并通过“ Office.onReady()”方法读取重复发生的内容
g_item.recurrence.getAsync --> Recurrence: valid value ('daily') // OK!
-
关闭任务窗格
-
打开任务窗格,并通过“ Office.onReady()”方法读取重复发生的内容
g_item.recurrence.getAsync --> Recurrence: valid value ('daily') // OK!
-
关闭任务窗格
-
将重复次数更改为“每周”
-
打开任务窗格,并通过“ Office.onReady()”方法读取重复发生的内容
g_item.recurrence.getAsync --> Recurrence: prevIoUs value ('daily') // ERROR??
***如果在第一个任务窗格打开时“无重复”,请关闭任务窗格,将重复更改为任意值,然后再次打开任务窗格->重复:null
我的“ onReady”方法:
Office.onReady(info => {
g_item = Office.context.mailBox.item;
if (!g_item.itemId) {
g_item.saveAsync(function (result) {
g_item.recurrence.getAsync((asyncResult) => {
if (asyncResult.status !== Office.AsyncResultStatus.Failed)
console.log("Recurrence: " + JSON.stringify(asyncResult.value));
});
});
}});
测试B:同步处理程序和按钮
我添加了一个同步处理程序和一个按钮。在“ onReady”方法中:
Office.context.mailBox.item.addHandlerAsync(Office.EventType.RecurrenceChanged,handler);
document.getElementById("button").onclick = onClick;
然后,打开任务窗格:
我的处理程序方法:
function handler(eventarg) {
console.log("handler. recurrence: " + JSON.stringify(eventarg.recurrence));
}
-
按我的按钮。重复跟踪具有OLD值(“每日”),但主题跟踪具有NEW值(与该项目中的其他值一样,但重复...)
function onClick() { g_item.recurrence.getAsync((result) => { // Recurrence: prevIoUs value ('daily') ERROR! if (result.status === Office.AsyncResultStatus.Succeeded) console.log("onClick. Recurrence: " + JSON.stringify(result.value)); }); g_item.subject.getAsync((result) => { // Subject: ALWAYS printed properly when changed!!! if (result.status === Office.AsyncResultStatus.Succeeded) console.log("onClick. Subject: " + JSON.stringify(result.value)); }); }
***如果选择了重复发生,然后打开了任务窗格,则onClick方法会正确读取该值。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)