0

I'm using Microsoft.TeamFoundation.WorkItemTracking.Client to fix some stuff. The request is: I have workitem with a field which has no data, now I need to update the workitem for that field, how can I make it?

    public void UpdateWorkItem(int workItemId, Dictionary<string, string> values)
    {
        if (workItemId <= 0) return;

        var workItem = tfsStore.GetWorkItem(workItemId);

        //now if I use workItem.Fields["updatingKey"] it'll throw exception since the field updatingKey does not exist in the Fields of the workitem.

    }
MuhanadY
  • 752
  • 1
  • 12
  • 40
Kevin
  • 1
  • Hi Kevin, any update? Just checking to see if the information provided was helpful. If my reply helped or gave a right direction. Appreciate for [marking it as an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) which will also helps others in the community. – PatrickLu-MSFT Apr 24 '20 at 09:51

1 Answers1

0

Once you have the Work Item you are going to modify, just change the value of the specific field you need to change:

workitem.Fields["Custom Field"].Value = "New Value";

Detail code snippet please take a look at this similar question: How to update a custom TFS field programmatically

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62