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.

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();
}
}
source
share