Outlook add in (calendar event): Recurrence is always null

后端 未结 3 359
粉色の甜心
粉色の甜心 2021-01-17 00:25

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         


        
相关标签:
3条回答
  • 2021-01-17 00:56

    With my test taskpane.js I did this test:

    1. Create a 'New event'

    2. Change the recurrence ('daily')

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

    4. Close the taskpane

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

    6. Close the taskpane

    7. Change the recurrence (to 'weekly')

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

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

    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));
                  });
              });
          }
    });
    

    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;
    

    with the taskpane open:

    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!

      My handler method:

       function handler(eventarg) {
           console.log("handler. recurrence: " + JSON.stringify(eventarg.recurrence));
       }
      
    2. 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));
          });
       }
      

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

    0 讨论(0)
  • 2021-01-17 00:57

    With the code you gave me in the comment, i get the recurrence when it changes:

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

    But only 'handler' function is called, where the recurrence is valid: console.log(JSON.stringify(eventarg.recurrence));

    • Why callback function is not called?
    • Why I can not get the recurrence with my function:

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

    In this case, handleRecurrenceChange is called but when I call item.recurrence.getAsync() i get result.value = null

    The same if I call item.recurrence.getAsync() when I need the recurrence (I get null)

    I would like to get the recurrence when I need it (I can get all other event values properly), without saving it when changed, if possible...

    Regards,

    Diego

    0 讨论(0)
  • 2021-01-17 00:57

    This issue has been fixed from our end on OWA. recurrence.getAsync() shouldn't be returning null anymore.

    0 讨论(0)
提交回复
热议问题