microsoft/azure-devops-extension-sdk

Critical Bug - Active work item document does not exist in the current context

Bilals2412 opened this issue · 6 comments

Dear Team,

I am writing to bring to your attention a critical issue I’ve encountered in my Azure DevOps extension. I am using the “azure-devops-extension-sdk” version “^3.1.2” and have built an extension for the work item. In this extension, I utilize the following code snippet:

workitemFormService = await SDK.getService<IWorkItemFormService>(
      WorkItemTrackingServiceIds.WorkItemFormService
);

This code works as expected, allowing me to retrieve work item information. However, I have identified a problem when opening a work item through the search bar at the top right. In this scenario, the service returns the following error message: “Active work item document does not exist in the current context”. This error consistently occurs whenever I open a work item via the search functionality.

Furthermore, there is an issue with this service when I have a work item opened in the background and then open a new work item via the search. In this case, the following command in the extension within work item 7 returns incorrect information:

console.log(await workitemFormService.getId());
The response is 13, even though I am on work item 7, as shown in the attached image.

2023-09-27_16h02_51

I would like to mention that the process works without opening the search bar and only there strong problems occurred.

Please prioritize providing us with an update promptly, as this bug is critical for our operations.

Best regards

maasha commented

I have the same issue. If you disable the New Boards Hub feature then it works for me.

We also experience the same problem. Is there a chance to get things going with that?

Recently, I followed a link that leads to this bug, and it was closed, and Azure DevOps started working as expected. Why has the bug reappeared?

With the old Boards Hub the azure-extension-sdk will report the current work item as the one in background window (work item 13 above). When creating a new work item, a modal will appear and and the sdk will provide that work item's id (work item 7 above) as the current work item - not so for with New Boards Hub enabled - then it will always provide the background work item as the current work item.

Now, with the New Boards Hub clicking any work item links will open this in a modal - that is new behaviour. In fact, you can have many modals open on top of each other. With the old Boards Hub you only get the modal when creating a new work item.

What we need, is access to the stack of modals so we can get the appropriate IDs.

With the old Boards Hub the azure-extension-sdk will report the current work item as the one in background window (work item 13 above). When creating a new work item, a modal will appear and and the sdk will provide that work item's id (work item 7 above) as the current work item - not so for with New Boards Hub enabled - then it will always provide the background work item as the current work item.

Now, with the New Boards Hub clicking any work item links will open this in a modal - that is new behaviour. In fact, you can have many modals open on top of each other. With the old Boards Hub you only get the modal when creating a new work item.

What we need, is access to the stack of modals so we can get the appropriate IDs.

Martin, have you tried to resolve this issue? Maybe by getting the ID through some library method? Possibly using the onLoaded or onRefreshed methods?

https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-workitem-extension?view=azure-devops#addmenuaction

By the way, I tried turning off the New Boards Hub, and the bug really went away. After I turned the New Boards Hub back on, the bug did not reappear.