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.
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));
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
This issue has been fixed from our end on OWA. recurrence.getAsync() shouldn't be returning null anymore.