My project requires me to programmatically access TFS servers that we donβt administer, and to receive real-time information about the fields in WorkItemTypes. I can get the field names and most of the information I need if I look at the FieldDefinition in the WorkItemType FieldDefinitions collection.
public WitType(WorkItemType type) { this.Fields = new List<string>(); foreach (FieldDefinition f in type.FieldDefinitions) { Fields.Add(f.Name); } }
One IsRequired property is missing. I need to know if a field is required. I tried to run a work item history query
WorkItemCollection workItemCollection = workItemStore.Query foreach (WorkItem workItem in workItemCollection) foreach (Field field in workItem.Fields) { textBox1.Text += field.Name + " is required? " + field.IsRequired.ToString(); }
and then checking the IsRequired property of the Field element in the Field Worktem collection. The only problem is that for a given work item of type one work item says that a header is needed, then the next work item will have the property IsRequired = false.
Is there a way to determine if a WorkItem field is required without resorting to a WIT xml file? If not, is there a way to programmatically access the WIT xml file?
source share