OfficeDev / office-js-docs

[ARCHIVED] Microsoft Office Add-ins API Reference Documentation
https://docs.microsoft.com/javascript/api/overview/office
398 stars 247 forks source link

Not documented: DialogHandler.sendMessage #1428

Closed jrop closed 6 years ago

jrop commented 6 years ago

The method DialogHandler.sendMessage is not documented.

Article URL

https://dev.office.com/reference/add-ins/shared/officeui.dialog

Issue

Hello. When I execute the following code, I notice that dialog posseses an undocumented function:

window.Office.context.ui.displayDialogAsync(
  loc,
  Object.assign(
    {
      displayInIframe: true
    },
    options
  ),
  asyncResult => {
    const dialog = asyncResult.value;
    console.log(dialog)
    // displays "OSF.DialogHandler {close: ƒ, addEventHandler: ƒ, sendMessage: ƒ}"
  }
);

As you can see at the above documentation link, only the following methods on Dialog are documented:

It would be good to have documentation for sendMessage as well, and also how to add handlers from within the child dialog to receive messages from the parent.

Thanks!

jrop commented 6 years ago

Furthermore if I add this code in the dialog:

// in dialog:
window.addEventListener('message', console.log(JSON.parse(e.data)))

And this in the task pane:

dialog.sendMessage(JSON.stringify({hello: 'World'}))

Then I see this logged in the console:

{
  _messageType: 1,
  _actionName: "executeMethod",
  _conversationId: "-bd8cd38_-70e7ac05_1527164401310",
  _correlationId: 5,
  _origin: "...",
  _data: { Error: 5000, Version: 1 },
  _errorCode: 0,
  _responseType: 0,
  _serializerVersion: 1
}
Rick-Kirkham commented 6 years ago

@jrop I will investigate, but I'm 99% sure that there really isn't such a method on that object, or there is but it's intended for internal use only by Microsoft, or its something that will eventually be previewed. Are you using the beta Office JavaScript library? What is the URL of the CDN that you are calling it from?

jrop commented 6 years ago

@Rick-Kirkham Thanks for the info. I am including from this URL:

https://appsforoffice.microsoft.com/lib/1/hosted/Office.js
Rick-Kirkham commented 6 years ago

@jrop Yes. I found it too. It's definitely there. The question is whether we support its use. I'm investigating.

Rick-Kirkham commented 6 years ago

@jrop This method is only supported in OneNote. I will add it to the documentation.

jrop commented 6 years ago

@Rick-Kirkham Thanks for the info

Rick-Kirkham commented 6 years ago

@jrop Lastest word is that we do not support its use even in OneNote. It is "For internal use only".

jrop commented 6 years ago

@Rick-Kirkham I appreciate you looking into this for me. Thank you for the detailed and timely information