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
687 stars 94 forks source link

Callback of goToByIdAsync is never fired #567

Closed va1729 closed 3 years ago

va1729 commented 5 years ago

Steps to Reproduce, or Live Example

Script lap scripts -

Context

I am trying to make the cursor go to a particular binding. The function goToByIdAsync takes me to the binding but the callback is never fired in Office Online. It works in Mac Word app though.

Your Environment

kbrandl commented 5 years ago

@Vivekananda-Athukuri apologies for the slow response, looks like this issue was overlooked until now. @weshi can you please investigate? Thanks!

AbidRahman-MSFT commented 3 years ago

Hey @va1729,

I apologize for the delay. It looks like in your sample, you're missing the .bindings property. I've changed the second function in your sample to the following:

function run2() {
  Office.context.document.bindings.getByIdAsync("myBinding", function(asyncResult) {
    if (asyncResult.status == Office.AsyncResultStatus.Failed) {
      console.log("Action failed. Error: " + asyncResult.error.message);
    } else {
      console.log("Go to binding with type: " + asyncResult.value.type + " and id: " + asyncResult.value.id);
    }
  });
}

The above snippet will now search for the binding with the "myBinding" id and can successfully log the type and id to the console: image

Closing the issue for now, please feel free to re-open if you have any further questions.