1

I'm trying to programmatically call standart "Create Work Item" window in Visual Studio 2012. I was trying to make it by using GUID of command, but it doesn't work.

 DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
 dte.Commands.Raise("{4BCF92C9-7FEA-4913-AF26-F93582BA9C7A}", 196608, null, null);

I was trying to find something in Microsoft.TeamFoundation.WorkItemTracking.Client, but it's not giving me the right result.

James Chevalier
  • 10,604
  • 5
  • 48
  • 74
Shinigami302
  • 103
  • 7

2 Answers2

1

If you have a Team Foundation Server setup, which it looks like you do, then you can probably achieve this by working through the tfs web portal. For me the "Create Work Item" is found under:

http://myserver:8080/tfs/<Collection>/<Project>/_workItems
dtmland
  • 2,136
  • 4
  • 22
  • 45
  • Thanks for the answer, dtmland, but I knew about this way - and this is not acceptable. My purpose - to cause default "Create Work Item" window in Visual Studio 2012. – Shinigami302 Aug 22 '13 at 07:56
1

I resolve my problem.

To programmatically call standart "Create Work Item" window in Visual Studio 2012, use DocumentService interface.

In my case it's look like this:

    using Microsoft.TeamFoundation.WorkItemTracking.Client;
    using Microsoft.TeamFoundation.WorkItemTracking;
    using Microsoft.VisualStudio.TeamFoundation;
    using Microsoft.VisualStudio.TeamFoundation.WorkItemTracking;
...
    private DTE dte;
    private EnvDTE80.DTE2 dte2;
...

    dte = Package.GetGlobalService(typeof(DTE)) as DTE;
    dte2 = (EnvDTE80.DTE2)dte;
    DocumentService documentService = dte2.DTE.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService")
                        as DocumentService;
    WorkItem workItem = new WorkItem(workItemType); // Use type what you need
    object a = new object();
    IWorkItemDocument widoc = docService.CreateWorkItem(workItem, a);
    docService.ShowWorkItem(widoc);
Shinigami302
  • 103
  • 7
  • I know this is an old thread, but has this changed in Visual Studio 2019? When I use that code, my documentService variable is null. (I believe this worked in VS 2017 though). – user0474975 Sep 11 '19 at 15:31