Outlook加载项日历事件:重复率始终为null

问题描述

我有一个用于日历事件的Outlook外接程序,带有一个任务窗格。从窗格中,获取事件数据:

   date start: item.start.getAsync()
   date end: item.end.getAsync()
   recurrence: item.recurrence.getAsync()

日期还可以,但是重复发生总是为空(状态='成功'),尽管我在事件中更改了重复发生...

可能是什么问题?

我用来开发Outlook 365 Web

谢谢

迭戈

编辑: 当重复发生更改时,我会收到此事件:

Office.context.mailBox.item.addHandlerAsync(Office.EventType.RecurrenceChanged,handleRecurrenceChanged);

但是在handleRecurrenceChanged()中,重复率始终为null ... *

解决方法

使用您在注释中给我的代码,当代码更改时,我会再次出现:

  Office.context.mailbox.item.addHandlerAsync(Office.EventType.RecurrenceChanged,handler,callback);

但是仅调用“处理程序”函数,其中重复有效:console.log(JSON.stringify(eventarg.recurrence));

  • 为什么不调用回调函数?
  • 为什么我的函数无法复发:

Office.context.mailbox.item.addHandlerAsync(Office.EventType.RecurrenceChanged,handleRecurrenceChange);

在这种情况下,将调用handleRecurrenceChange,但是当我调用item.recurrence.getAsync()时,我将得到result.value = null

需要重复出现时调用item.recurrence.getAsync()相同(得到null)

我想在需要时获取重复(我可以正确获取所有其他事件值),如果可能的话,不保存它。

此致

迭戈

,

使用我的测试taskpane.js,我做了这个测试:

  1. 创建“新事件”

  2. 更改重复周期(“每日”)

  3. 打开任务窗格,并在“ Office.onReady()”方法中读取重复情况 g_item.recurrence.getAsync->重复:有效值(“每日”)//确定!

  4. 关闭任务窗格

  5. 打开任务窗格,并在“ Office.onReady()”方法中读取重复情况 g_item.recurrence.getAsync->重复:有效值(“每日”)//确定!

  6. 关闭任务窗格

  7. 将重复次数更改为“每周”

  8. 打开任务窗格,并在“ Office.onReady()”方法中读取重复出现的内容 g_item.recurrence.getAsync->重复发生:以前的值(“每日”)//错误!

***如果在第一个任务窗格打开时“无重复”,请关闭任务窗格,将重复更改为任意值,然后再次打开任务窗格->重复: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));
              });
          });
      }
});

我添加了一个同步处理程序和一个按钮。在“ onReady”方法中:

Office.context.mailbox.item.addHandlerAsync(Office.EventType.RecurrenceChanged,handler);
document.getElementById("button").onclick = onClick;

打开任务窗格:

  1. 将重复发生时间从“每日”更改为“每周”,并更改事件主题 ->重复处理程序称为TWICE: a)旧的重复值(“每日”)//错误? b)新值(“每周”)//确定!

    我的处理程序方法:

     function handler(eventarg) {
         console.log("handler. recurrence: " + JSON.stringify(eventarg.recurrence));
     }
    
  2. 按我的按钮。重复跟踪具有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方法会正确读取该值。

,

此问题已从OWA的问题修复。 recurrence.getAsync()不应再返回null。