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
With my test taskpane.js I did this test:
Create a 'New event'
Change the recurrence ('daily')
Open the taskpane and read the recurrence in the 'Office.onReady()' method
g_item.recurrence.getAsync
--> Recurrence: valid value ('daily') // OK!
Close the taskpane
Open the taskpane and read the recurrence in the 'Office.onReady()' method
g_item.recurrence.getAsync
--> Recurrence: valid value ('daily') // OK!
Close the taskpane
Change the recurrence (to 'weekly')
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:
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));
}
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.