I can't pass information from a dialog window to parent add-in
calling Office.context.ui.messageParent from displayDialog shuld notify the function registered with addEventHandler(Office.EventType.DialogMessageReceived,...) in a Word add-in
the call does not activate the manager registered in the addin
//From add-in
Office.context.ui.displayDialogAsync(`login`, { },asyncResult => {
const dialog = asyncResult.value;
const processMessage = (arg)=> {console.log('loggedin')}
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
})
//From the Dialog
Office.context.ui.messageParent('Hello');
Maybe the problem is in the postDialogMessage function, the value of o.protocol.hostname is undefined
I am experiencing the same issue. Oddly, when I use this url to load to office scripts: https://appsforoffice.microsoft.com/lib/1/hosted/Office.js
I get this error in the console of the dialog window:

When I use this url(not the casing on "office"): https://appsforoffice.microsoft.com/lib/1/hosted/office.js
I get no error in console, but it still doesnt work.
And when I use the url from the npm CDN: https://unpkg.com/@microsoft/office-js/dist/office.js
It works as expected with message being sent. I am guessing that the npm CDN still didnt get the latest version with the bug introduced.
Could you please take a look at this, as this is serious issue for word web user, that for example cant login to the app if the dialog is used for login. Thanks!
@lliu113 We are also seeing this problem on Edge Chromium. Users of any of our add-ins on Word for the web are unable to sign in when using the DialogAPI flow.
We consider this a serious issue as it makes our add-in unusable in this context.
Note: The DialogAPI works fine on PowerPoint and Excel for the web.
Note: It actually works on IE11
@lliu113 @nickxbs It appears that this issue is resolved on our side 馃憤
@htryggva we moved to npm version. I think changing cdn content without changing the endpoint should be unsafe for us.
@nickxbs @htryggva Isn't it the case that Office.js team recommends using the CDN url (that is always the same) for production apps, and not npm package (see https://github.com/OfficeDev/office-js#support)? If that is the case, then why CDN tends to break? What is the safer to use in the future?
@nickxbs @greatescape95 Happy to hear that the NPM version fixes the issue for you but our add-in is published on AppSource, which means that we have to use the CDN version according the submission guidelines:
Certification Policies - 1120.1 Easy identification
All Office add-ins must use the latest version of the Microsoft-hosted Office.js file at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
With that in mind, the CDN version should be the 'safe' version to use, but unfortunately that is not always the case.
@htryggva @greatescape95 the lib was modified without changing the versioning of cdn. As you can see my plugin was broken overnight, due to this bug, from 25 days... This is unsafe for me.
The npm version is older but can be managed and versioned
@lliu113 @nickxbs @htryggva it seems the issue is on microsoft production again! dialog api communication is not working for me in word online app, but this time there is even no error in the console. I again made the same fix as last time (using office js from npm instead from official CDN). It is bad we need to introduce these hacks in our codebase just to make basic things to work.
@greatescape95 - sorry for the very belated response to this. I agree that having to switch to using the npm version of officejs instead of the official CDN is not ideal. Let me open a bug to investigate.
Just to reiterate - using the official CDN means that the messageParent API does not work. However, switching to the npm version fixes the issue.
Most helpful comment
@htryggva @greatescape95 the lib was modified without changing the versioning of cdn. As you can see my plugin was broken overnight, due to this bug, from 25 days... This is unsafe for me.
The npm version is older but can be managed and versioned