Search code examples
c#tfstfs-sdk

TFS API C#: Change work item through C#


I need to change field AssignedTo and ReadyForQA in a WorkItem, it does not exist in instance of class WorkItem though. I need to take value from field CreatedBy and set it to field AssignedTo, in addition I need to set field ReadyForQA to "Yes". It exists in TFS GUI: enter image description here However is doesn't exists in object that returns from query: enter image description here As far as I am concerned, TFS GUI and fields are dynamic and can be created and modified through TFS SQL Database, but maybe exists some way to modify these fields?


Solution

  • Check the .Fields["System.FieldName"].Value property on the Work Item object. Since the values are configurable for each workitem, there are no direct property accessors.

    You can use the CoreField enum to find system default fields, your custom field you'll need to access by passing the name. Prefer passing the Enum, then the Reference Name. Don't pass in the Display name. While passing in the Display Name will work, it's a brittle solution.