I am attempting to transmit data to a dialog box within 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')
});
This code opens a dialog box and tries to pass information to the dialog using the following 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, upon running this code, I encounter the error message:
TypeError: Office.context.ui.addHandlerAsync is not a function
Upon logging console.log(Office.context.ui)
, the output indicates:
OSF.DDA.UI.ParentUI
[[Prototype]]:Object
closeContainer:function(){ … }
displayDialogAsync:function(){ … }
openBrowserWindow:function(){ … }
__proto__:Object
It is evident that there is no addHandlerAync
function found in Office.context.ui
, despite it being recommended by Microsoft's documentation.
What could be causing this issue? Any help would be appreciated. Thanks