Accessing TFS Work Item Properties "Blocked" & "Root Cause" using TFS API

621 Views Asked by At

Can anyone tell me how I can access the properties "Blocked" & "Root cause" of a Work Item?

I tried the following but it doesn't seem to be right:

// Code to connect to TFS

WorkItem workItem = workItemStore.GetWorkItem(1234);

string blocked = workItem.Fields["Blocked"].Value.ToString();
string rootCause = workItem.Fields["Root Cause"].Value.ToString();    
1

There are 1 best solutions below

0
On

The code seems correct to me. What is the type of the work item you are using? What is the process template of the team project?

"Blocked" field only exists in 'Bug', 'Requirement', 'Risk', 'Task' types in CMMI process template and 'Task' type in Scrum template. "Root Cause" field exists in 'Bug' and 'Issue' types in CMMI process template