Reputation: 182
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.
Upvotes: 4
Views: 2086
Reputation: 730
DialogApi 1.2 got a new feature messageChild
: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/dialog-api-in-office-add-ins#use-messagechild-from-the-host-page
Upvotes: -2
Reputation: 7
You can use this in parrent before usedisplayDialog
:
localStorage.setItem("clientID", "15963ac5-314f-4d9b-b5a1-ccb2f1aea248");
And then in your JavaScript file:
var clientID = localStorage.getItem("clientID");
Upvotes: 0
Reputation: 9659
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.
Upvotes: 4