microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions
MIT License
123 stars 38 forks source link

Error calling the IWorkItemFormNavigationService on an on-premise #23

Open edtro opened 4 years ago

edtro commented 4 years ago

Dear, I am running into an error on an on-premise instance of Azure DevOps 2019. The same extension installed on an online organization, is working fine.

This the source code (typescript): const navigationService = await SDK.getService<IWorkItemFormNavigationService>(WorkItemTrackingServiceIds.WorkItemFormNavigationService); if (typeof navigationService != 'undefined' && navigationService != null) { navigationService.openWorkItem(id, false); } else { throw new Error("Could not load WorkItemFormNavigationService from the SDK"); }

It is failing on the call to .getService() with the following message: ` message: "No contribution provider or uri for ms.vss-work-web.work-item-form-navigation-service."

stack: "Error: No contribution provider or uri for ms.vss-work-web.work-item-form-navigation-service. at t.getBackgroundHost (https://myserver.be/tfs/_static/_ext/ms.vss-web/ext-content/ms.vss-web.ext-content.luCfz4YwcHM3_pJR.min.js:1:19120) at t.getService (https://myserver.be/tfs/_static/_ext/ms.vss-web/ext-content/ms.vss-web.ext-content.luCfz4YwcHM3_pJR.min.js:1:18834) at https://myserver.be/tfs/_static/_ext/ms.vss-web/platform-content/ms.vss-web.platform-content.xjg1YXj9NZN2H2LQ.min.js:1:21067" `

I have found a temporary workaround that works (but not as nice as it should) const commonNavigationService = await SDK.getService<IHostNavigationService>(CommonServiceIds.HostNavigationService); if (typeof commonNavigationService != 'undefined' && commonNavigationService != null) { console.warn("Could not load WorkItemFormNavigationService from the SDK. Workaround applied.") commonNavigationService.navigate(editUrl); } else { throw new Error("Could not load HostNavigationService from the SDK"); } Can someone please take a look?

Thanks in advance.

Kr. Edward Trouw