The main issue is that appointmentResponse is not returning responses. It's returns undefined. It's is documented as returning MailboxEnums.ResponseType.
I'm also pointing out potential issues the the sample code on the documentation page this issue was reported from.
Gets the response that an attendee returned for an appointment. This property applies to only an attendee of an appointment, as represented by the optionalAttendees or requiredAttendees property. This property returns undefined in other scenarios.
var requiredAttendees = Office.context.mailbox.item.requiredAttendees;
console.log("There are " + requiredAttendees.length + " required attendees.")
requiredAttendees.forEach(function (requiredAttendee) {
console.log("Attendee " + requiredAttendee.displayName + ": " + requiredAttendee.appointmentResponse);
});
Are these examples correct? I don't see them calling getAsync. The examples do not work for me. Additionally, following the pattern of calling getAsync, I still can't access appointmentResponse.
Code sample:
let item = Office.context.mailbox.item,
requiredAttendees, optionalAttendees, totalAttendees = 0;
if (item.itemType === Office.MailboxEnums.ItemType.Appointment) {
requiredAttendees = item.requiredAttendees;
optionalAttendees = item.optionalAttendees;
if (requiredAttendees) {
requiredAttendees.getAsync((asyncResult) => {
console.log(asyncResult.value);
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
totalAttendees += asyncResult.value.length;
for (let i = 0; i < asyncResult.value.length; i++) {
console.log(asyncResult.value[i].displayName + ' | ' +
asyncResult.value[i].appointmentResponse + ' | ' +
asyncResult.value[i].recipientType + ' | ' +
asyncResult.value[i].emailAddress);
}
}
});
}
}
Question on stackoverflow for additional details:
https://stackoverflow.com/questions/54837540/is-it-possible-to-retrieve-appointment-responses-from-attendees
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@danjyoung thank you for bringing this documentation issue to our attention; we'll investigate and update the docs as appropriate.
@ElizabethSamuel-MSFT is this an issue that you could follow-up with the Outlook product team folks about (and update the docs accordingly)?
I've verified that this does not work on Outlook Win32 desktop, and also not on OWA, in appointment compose scenarios.
It DOES work on Appointment Read Scenarios (which I realize is less useful than Appointment Compose)
i.e. just doing something like
JSON.stringify(Office.context.mailbox.item.requiredAttendees)
will produce:
[{"emailAddress":"[email protected]","displayName":"Joe Contoso","appointmentResponse":"organizer","recipientType":"other"},{"emailAddress":"[email protected]","displayName":"Bob Contoso","appointmentResponse":"none","recipientType":"other"}]
I've opened an issue on our backlog, but can't give an update on when/if it will be fixed.
@danjyoung: In the meantime, I'll indicate this condition/limitation on the sample.
I updated the sample to indicate this condition/limitation. That should be published soon (likely this week).
@exextoc -- thanks for confirming this limitation and for confirming that it's now being tracked in the team's backlog, and @ElizabethSamuel-MSFT -- thanks for updating the sample. FYI for all -- I'm going to transfer this issue to the OfficeDev/office-js repository now (the place where product/platform-related issues are tracked.)
@danjyoung I tried following code and now I am able to get number of attendees who accepted/declined/gave no response. Can you Please try this once and let us know whether it helps-
var requiredAttendees = Office.context.mailbox.item.requiredAttendees;
console.log("There are " + requiredAttendees.length + " required attendees.")
var accepted=0;
var declined=0;
var none=0;
requiredAttendees.forEach(function (requiredAttendee) {
if(requiredAttendee.appointmentResponse == 'none')
none++;
if(requiredAttendee.appointmentResponse == 'accepted')
accepted++;
if(requiredAttendee.appointmentResponse == 'declined')
declined++;
console.log("Attendee " + requiredAttendee.displayName + ": " + requiredAttendee.appointmentResponse);
});
console.log("No Response or Accepted but selected do not send response:" + none);
console.log("Accepted:" + accepted);
console.log("Declined:" + declined);