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
690 stars 95 forks source link

Word Addin - Table Bindings not working recently #3391

Open rajasaur opened 1 year ago

rajasaur commented 1 year ago

We have a word addin, that has been working for more than 2 years and quite recently (maybe a month or so ago), it has stopped working when binding table entries using the addFromNamedItemSync.

This still works on Microsoft Word for Mac, but doesnt work on Office 365 Online or Microsoft Word for Microsoft 365 MSO.

This is how we are trying to do the binding.

for (let i = 0; i < tables.items.length; i++) {
   contentControl = tables.items[i].insertContentControl();
   contentControl.title = `Table-${ i + 1 }`;
}
return context.sync().then(() => {
   for (let i = 1; i <= tables.items.length; i++) {
      Office.context.document.bindings.addFromNamedItemAsync(
           `Table-${i}`, 
           Office.BindingType.Table, 
           {}, 
           (asyncResult) => {
              if (asyncResult.status == Office.AsyncResultStatus.Failed) {
                  console.log(asyncResult.error.message);
              } else {
                  asyncResult.value.addHandlerAsync(
                        Office.EventType.BindingSelectionChanged,
                        selectionHandler, 
                        (asyncR) => {}
                  );
              }
          });
      }
 });

This code works perfectly on MS word on Mac and the bindings are created properly but not on the other platforms.

On the other platforms (Online and Microsoft Word for Microsoft 365 MSO), we get a Error with message as The specified data object is not compatible with the binding type. with Code as 2008.

I have tried updating my Office JS versions to the latest to see if it would get resolved but that doenst seem to help either.

Can someone help if there are any changes needed in the latest word addin or if we are making any errors .

Your Environment

Expected behavior

Expect the table bindings to be registered so that any selections will allow us to get the row/column number for us to fill values.

Current behavior

The table bindings throw a "The specified data object is not compatible with the binding type" with Code as 2008.

Steps to reproduce

Code available above, That has been working for about 2 years now, and suddenly the bindings have not worked for the last month or so.

Link to live example(s)

This is the plugin available at https://appsource.microsoft.com/en-gb/product/office/wa200002262?tab=overview&exp=ubp8. I can provide some login credentials if needed.

ghost commented 1 year ago

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

rajasaur commented 1 year ago

I can get a simple addon if it will help reproduce the issue but it does seem like an internal one that we arent able to debug at a browser level. Any help would be greatly appreciated as it limits the functionality of our addon

rajasaur commented 1 year ago

Any help on debugging this be great as Ive checked the JS code and the call from addFromNamedItemAsync seems to be returning Error: 2008. I cant trace any further with Office365.

Im also a little confused as the Error Code 2008 corresponds to "Data Write Error" and 2007 is the one for invalid binding as per https://learn.microsoft.com/en-us/office/dev/add-ins/reference/javascript-api-for-office-error-codes

xiruatms commented 6 months ago

@rajasaur , thanks for reporting this. Will you please provide us a simple addin and/or testing document for us to continue?

rajasaur commented 6 months ago

The addin for testing is available at https://appsource.microsoft.com/en-gb/product/office/wa200002262?tab=overview&exp=ubp8 I can provide a login/password to the system when you are testing it. Can I message you private to send the login credentials or to your email ?