本文介绍了Outlook 添加(日历事件):重复始终为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于日历事件的 Outlook 插件,带有一个任务窗格.从窗格中,我得到了事件数据:

I have an Outlook addin for calendar events, with a task pane. From the pane, I get the event data:

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

日期没问题,但重复总是为空(status = 'succeeded'),虽然我在事件中更改了重复...

Dates are ok, but recurrence is always null (status = 'succeeded'), although I change the recurrence in the event...

可能是什么问题?

我正在使用开发 Outlook 365 Web

I am using to develop Outlook 365 Web

谢谢,

迭戈

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

I receive the event when recurrence is changed:

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

但在 handleRecurrenceChanged() 中,重复总是为空...*

But in handleRecurrenceChanged() recurrence is always null...*

推荐答案

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

With my test taskpane.js I did this test:

  1. 创建一个新活动"

  1. Create a 'New event'

更改重复周期(每日")

Change the recurrence ('daily')

打开任务窗格并在 'Office.onReady()' 方法中读取重复g_item.recurrence.getAsync -->重复:有效值 ('daily')//好的!

Open the taskpane and read the recurrence in the 'Office.onReady()' methodg_item.recurrence.getAsync --> Recurrence: valid value ('daily') // OK!

关闭任务窗格

打开任务窗格并在 'Office.onReady()' 方法中读取重复g_item.recurrence.getAsync -->重复:有效值 ('daily')//好的!

Open the taskpane and read the recurrence in the 'Office.onReady()' methodg_item.recurrence.getAsync --> Recurrence: valid value ('daily') // OK!

关闭任务窗格

更改重复周期(改为每周")

Change the recurrence (to 'weekly')

打开任务窗格并在 'Office.onReady()' 方法中读取重复g_item.recurrence.getAsync -->重复:以前的值('daily')//错误!

Open the taskpane and read the recurrence in the 'Office.onReady()' methodg_item.recurrence.getAsync --> Recurrence: previous value ('daily') // ERROR!

*** 如果第一次打开任务窗格时没有重复",请关闭任务窗格,更改重复(任何)并再次打开任务窗格 -->重复:null

*** If 'no recurrence' when taskpane 1st open, close taskpane, change recurrence (to any) and open taskpane again --> Recurrence: null

我的onReady"方法:

My 'onReady' method:

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"方法中:


I add a sync handler and a button. In the 'onReady' method:

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

任务窗格打开:

  1. 将重复周期从每日"更改为每周"并更改活动主题-->重复处理程序称为 TWICE:a) OLD 重复值 ('daily')//错误?b) 新值 ('weekly')//好的!

  1. Change recurrence from 'daily' to 'weekly' and Change event subject--> Recurrence handler is called TWICE:a) OLD recurrence value ('daily') // ERROR?b) NEW value ('weekly') // OK!

我的处理方法:

 function handler(eventarg) {
     console.log("handler. recurrence: " + JSON.stringify(eventarg.recurrence));
 }

  • 按下我的按钮.重复跟踪具有 OLD 值('daily'),但主题跟踪具有 NEW 值(与项目中的其他值一样,但重复......)

  • Press my button. Recurrence trace has the OLD value ('daily'), but subject trace has the NEW value (like the other values from the item but the recurrence...)

     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 方法会正确读取值.

    *** If recurrence is selected and then taskpane is open, onClick method read the value properly.

    这篇关于Outlook 添加(日历事件):重复始终为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    07-06 22:42