I am trying to send information to a dialog box in an Outlook web-add in.
var url = window.location.origin+'/dialog.html'
var dialog
Office.context.ui.displayDialogAsync(url2,
function (asyncResult) {
dialog = asyncResult.value;
dialog.messageChild('message')
});
Which opens a dialog box and tries to send information to the dialog which has this Javascript:
Office.onReady().then(()=> {
Office.context.ui.addHandlerAsync(
Office.EventType.DialogParentMessageReceived,
onMessageFromParent);
});
function onMessageFromParent(arg){
console.log(arg.message)
document.getElementById('ID').style.display = 'none';
}
However, that just gives me the error:
TypeError: Office.context.ui.addHandlerAsync is not a function
When I run console.log(Office.context.ui), I get:
OSF.DDA.UI.ParentUI
[[Prototype]]:Object
closeContainer:function(){ … }
displayDialogAsync:function(){ … }
openBrowserWindow:function(){ … }
__proto__:Object
As you can see, there is not a addHandlerAync function within Office.context.ui but the Microsoft documentation says to use it.
What is going wrong here? Thanks
I look at your add-in. Its taskpane.html is not completed yet and the JavaScript is not included. However, I manually load the dialog page in the debugger and I confirm that your code in dialogbox.html is working. I can see Office.context.ui.addHandlerAsync is available in the Office.onReady handler. Would you like to fix your add-in and double check it's working?