Tim
Tim

Reputation: 2911

Adding Priority to a TFS WorkItem

I am writing code in VB to programmatically enter new WorkItems in TFS. I am able to set most of the fields correctly, but I cannot figure out how to set the Priority.

I set fields in the following manner:

        WorkItem task = project.WorkItemTypes["TASK"].NewWorkItem();
        task.Title = "Test Task";
        task.Description = "This is a task that must be tested.";
        task.Fields["Original Estimate"].Value = 10;
        task.Fields["Remaining Work"].Value = 6;
        task.Fields["Completed Work"].Value = 4;
        task.Fields["Assigned To"].Value = "Test User";

If anyone has any information on how to set the Priority, I would be very grateful.

Upvotes: 0

Views: 671

Answers (1)

DaveShaw
DaveShaw

Reputation: 52818

You can set it using the name or refName:

  • task.Fields["Priority"].Value
  • task.Fields["Microsoft.VSTS.Common.Priority"].Value

on the WorkItem.

The reason it is not available as a property, is that only items with a refName in System appear on the WorkItem class. I guess this give MS freedom to change / remove anything not in System from Work Items / Templates that do not need it.

Upvotes: 1

Related Questions