OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

[Word online] Unable to read contentControls and other properties after a simple redirection #4875

Open quefournier opened 2 weeks ago

quefournier commented 2 weeks ago

Since the end of July, we have encountered an issue with our add-in (SharePoint manifest) when reading contentControls (as well as other properties) in Word documents. The scenario is as follows: we have a simple HTML login page that redirects (once the user is logged in) to the index page of our add-in. In cases where the document already contains the add-in information (i.e., on an existing document where the add-in was inserted), after being redirected from the login page, we are unable to access the properties of our document. Once these properties are loaded with .load(), the call to context.sync() will either never resolve correctly or cause a crash of the pane containing the add-in.

Your Environment

Current behavior

When opening a Word document, if it already contains the information from our SharePoint add-in, we are unable to read the contentControls of the document after being redirected from our login page. Note: To reproduce this bug correctly, the manifest must be available on SharePoint. Inserting a manifest from a local file will not allow this bug to be reproduced.

Steps to reproduce

  1. Create a new document and insert the app using the manifest from sharepoint
  2. Click the connect button
  3. You are redirected to the add-in main page. The document's contentControls should be logged in the console after being read correctly
  4. Refresh the window or tab where your Word document is located (f5)
  5. Click the connect button again
  6. After being redirected to the add-in main page for the second time the context.sync() call will either not resolve or the add-in page will crash

Link to live example(s)

We cannot reproduce the issue in Script Lab because it involves a redirection and, presumably, a SharePoint manifest.

You can use the attached files and set it up like this:

  1. Use a manifest hosted on Sharepoint and make it's sourceLocation points to the following page : (in attachements) connectionPage.html
  2. Make the above mentionned document.location.href = "" points to the following page: (in attachements) al-addin.html. The code in this scenario was shrunk to the extreme.

Context

Our clients can no longer use our 'template documents' (empty documents that already contain the information from our SharePoint add-in) and import and manage data through our add-in.

Useful logs

On screenshot 1. the addin is inserted and the contentControls are loaded and display correctly in the console. On screenshot 2. the page was reloaded, and after loading our contentControls the add-in crash at the context.sync() command. You can check the code on the attached html pages

shanshanzheng-dev commented 1 week ago

Hi @quefournier Thanks for reporting this issue. About sharePoint manifest, do you mean this? https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/explore-the-app-manifest-structure-and-the-package-of-a-sharepoint-add-in If yes, The SharePoint Add-In model in SharePoint Online has been deprecated as of November 27th 2023, checkout thefull retirement announcement to learn more. Thanks

quefournier commented 1 week ago

Well not quite. I'm not taking about a Sharepoint add-in but an Office add-in manifest file that is "Sharepoint hosted" (stored on our Sharepoint appcatalog).

shanshanzheng-dev commented 1 week ago

@quefournier We'll take a look and report back if we have a suggestion for you. Thanks.