问题
We use a dialog in our Outlook add-in for authentication. We have logic in our add-in that first checks for dialog API support, then checks if the add-in is framed - in which case it pops a new window for authentication instead. Recently the dialog API lit up for OWA, and has caused us a couple issues.
We fixed some previous issues relating to the order in which we performed authentication (we use ADAL.js
) and initializing Office. However, once we were past those, it doesn't appear the dialog can communicate back to the add-in using Office.context.ui.messageParent
.
Additionally, even though the add-in subscribes to Microsoft.Office.WebExtension.EventType.DialogEventReceived
events, they don't get fired when the dialog is closed (typically closing a dialog returns a 12006
error code, which we guard for).
I created a simple Outlook add-in that solely opens a dialog, and verified that it still can't communicate with the add-in in OWA. I've included the code below.
Add-in code:
Office.initialize = function (reason) {
$(document).ready(function () {
var resultArea = $("span");
$("button").click(function () {
resultArea.text("Opening dialog");
Office.context.ui.displayDialogAsync(
window.location.origin + "/TestAddin/Dialog.html",
{ height: 75, width: 25 },
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
var dialog = asyncResult.value;
dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, function handleAuthDialogMessage(message) {
dialog.close();
resultArea.text(message);
});
dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogEventReceived, function handleAuthDialogMessage(message) {
resultArea.text("Event encountered");
});
} else {
resultArea.text("Dialog failed");
}
});
});
})
};
Dialog code:
Office.initialize = function (reason) {
$(document).ready(function () {
Office.context.ui.messageParent("dialog-opened");
})
};
For now I've adjusted our add-in to first check to see if it is framed (in which case it opens a new window for authentication) before it checks for or uses the dialog API. This approach allows us to fix our production bug, and re-enable OWA authentication; however, I would like to uptake the dialog once it's working or our add-in is fixed :)
Is anyone aware of this issue already?
--- Update 2/22 ---
It appears that the dialog can now message parents. Unfortunately there's still an outstanding bug where closing the dialog doesn't trigger an event to be sent to the add-in.
回答1:
Could not reproduce the message parent issue.
Regarding DialogEventReceived events not firing when the dialog is closed - this is a known issue that we are working on a fix for already, but thanks for reporting!
来源:https://stackoverflow.com/questions/42147758/owa-dialog-api-support