i m stuck on simple problem with TFS API, when im getting work item, i cant get workitem Effort data, the idea is to get work item form the TFS by specific criteria, and then change Effort data and save it back to the TFS. Now i can get work item, and update any data by field, but i din;t found how to get Effort, and update it.
Query for getting 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 fetch 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'm getting all tasks that i need by specific query, and then i have method to pull 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 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();
}
}