Question

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.

Was it helpful?

Solution 2

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);

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top