We would like to use the Dialog API for some extra operations which are better suited to a larger work area. We already have the ability via the API to message the parent from the dialog (Office.context.ui.messageParent), however we would also like the ability to directly message the dialog, like a sendMessage function, for example:
var dialog;
Office.context.ui.displayDialogAsync('https://myDomain/myDialog.html', function (asyncResult) {
if (asyncResult.status === "failed") {
showNotification(asynceResult.error.code = ": " + asyncResult.error.message);
} else {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
dialog.sendMessage({ /* my payload */ }); //???
}
});
There are a couple of options to pass data from the parent to the child:
displayDialogAsync(myUrl + "?myMessage=...", function...)localStorage.setItem("DIALOG_MESSAGE", myMessage)However, both of these can only really be used on initialization of the dialog, they do not provide a nice way to do asynchronous messaging.
That is a popular request (and a good idea), but it is not supported yet. Please go to Office Dev User Voice and vote up the "Improve Custom Dialog" suggestion there or create a new suggestion of your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With