TFS API retrieves work item data

im stuck in a simple problem with the TFS API, when I get the work item, I can’t get the Workatem Effort data, the idea is to get the work item to generate TFS according to certain criteria and then change the Gain data and save it back to TFS. Now I can get the work item and update any data on the field, but I did not find how to get Effort and update it.

enter image description here

Request for receiving data from TFS:

SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'Task' AND [Assigned to] = 'name' 
ORDER BY [System.WorkItemType], [System.Id]

And this is the code to get the fields

public void getDataFromTfs()
{
    Console.WriteLine("Getting data from TFS to Store");
    Console.WriteLine("*********************");
    setQuery();
    Console.WriteLine("Query" + byTasksModified.ToString());
    Console.WriteLine("*********************");
    Console.ReadLine();
    credentials = new System.Net.NetworkCredential("xxxxx", "xxxxxx", "xxxxx");
    TfsTeamProjectCollection teamProjectCollection =
    new TfsTeamProjectCollection(new Uri(@"LINK HERE"), credentials);
    teamProjectCollection.EnsureAuthenticated();
    Store = (WorkItemStore) teamProjectCollection.GetService(typeof(WorkItemStore));
    WIC = Store.Query(byTasksAssignedTo);
    Console.WriteLine("Data fetched into Store");
    foreach (WorkItem workItem in WIC)
    {
        Console.WriteLine("ID: {0}", workItem.Id);
        Console.WriteLine("Title: {0}", workItem.Title);
    }
}

Here I get all the tasks that I need for a specific request, and then I have a method for performing a specific task

public void getSpecificWorkItemData()
{
    workItem = Store.GetWorkItem(64);
    Console.WriteLine("ID: {0}", workItem.Id);
    Console.WriteLine("Title: {0}", workItem.Title);

    workItem.Open();
    Console.ReadLine();
}

and then I have an update method for the task

public void updateWorkItem()
{
   workItem.Fields["Assigned to"].Value = "NAME";

   if (workItem.IsValid() == false)
   {
       Console.WriteLine("Item is not valid");
   }
   else
   {
        try
        {
            workItem.Save();
        }
        catch (ValidationException exception)
        {
            Console.WriteLine("Error saving work item!");
            Console.WriteLine(exception.Message);
        }
        Console.WriteLine("Item Saved");
        workItem.Close();
        Console.ReadLine();
    }
}
+4
source share
1

, . "", "". , "", :

Process Template    | Field (s)
Scrum               | Remaining Work
MSF Agile           | Remaining Work, Completed Work, Original estimate
MSF CMMI            | Remaining Work, Completed Work, Original estimate

"", , Scrum (Item Backlog Item Bug ):

Process Template    | Field (s)
Scrum               | Effort
MSF Agile           | Story Point
MSF CMMI            | Size

"" Scrum Process, , " " " ":

SELECT * 
    FROM WorkItems 
    WHERE [System.TeamProject] = @project  
        AND  [System.WorkItemType] IN GROUP 'Requirement Category'  
    ORDER BY [System.Id]

"", " " " ", "":

SELECT id, Microsoft.VSTS.Scheduling.CompletedWork, Microsoft.VSTS.Scheduling.RemainingWork, Microsoft.VSTS.Scheduling.OriginalEstimate
    FROM WorkItems 
    WHERE [System.TeamProject] = @project  
        AND  [System.WorkItemType] IN GROUP 'Task Category'  
    ORDER BY [System.Id]

Ref, TFS, :

workItem.Fields["Microsoft.VSTS.Scheduling.CompletedWork"].Value = 123;
workItem.Fields["Microsoft.VSTS.Scheduling.RemainingWork"].Value = 123;
workItem.Fields["Microsoft.VSTS.Scheduling.OriginalEstimate"].Value = 123;
+6

All Articles