I want to create a new work item in TFS using the SDK, and I'd like to set the item's effort estimates. My code at the moment looks like this
var coll = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://galaxy:8080/tfs/crisp"));
var workItemService = coll.GetService<WorkItemStore>();
var parent = workItemService.GetWorkItem(parentWorkItemId);
WorkItemType workItemType =parent.Project.WorkItemTypes
.Cast<WorkItemType>()
.First(candidateType => candidateType.Name.Equals("Task"));
WorkItem item = workItemType.NewWorkItem();
item.Title = work.Name;
//Set effort estimate here
workItemService.BatchSave(new WorkItem[]{ item });
But there doesn't seem to be anything on the interface for WorkItem which allows me to set an effort estimate. Does anyone know how this is done?
Turns out it's done by using the []
operator on the WorkItem
object.
var coll = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://galaxy:8080/tfs/crisp"), new UICredentialsProvider());
var workItemService = coll.GetService<WorkItemStore>();
var parent = workItemService.GetWorkItem(parentWorkItemId);
WorkItemType workItemType =parent.Project.WorkItemTypes
.Cast<WorkItemType>()
.First(candidateType => candidateType.Name.Equals("Task"));
WorkItem item = workItemType.NewWorkItem();
item.Title = "A name";
item["Original Estimate"] = duration.TotalHours;
item["Completed Work"] = duration.TotalHours;
item["Remaining Work"] = 0.0;
int workItemId = item.Save();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With