Reputation: 9
I have added a custom state in a Scrum Process Template but API is not giving newly added state until I create a new project based on that customized process template.
Every time I have to create project as a resolution to resolve this issue. What can I do to fix this issue?
WorkItemStore workItemStore = this.tfsTeamProjectCollection.GetService<WorkItemStore>();
int projectConunt = workItemStore.Projects.Count;
for (int i = 0; i < projectConunt; i++)
{
WorkItemTypeCollection workItemTypeCollection = workItemStore.Projects[i].WorkItemTypes;
for (int j = 0; j < workItemTypeCollection.Count; j++)
{
string workitemType = workItemTypeCollection[j].Name;
for (int k = 0; k < workItemTypeCollection[j].FieldDefinitions.Count; k++)
{
Microsoft.TeamFoundation.WorkItemTracking.Client.FieldDefinition fieldDefinition =
workItemTypeCollection[j].FieldDefinitions[k];
if (filedRefName == fieldDefinition.ReferenceName)
{
List<string> allowedValues = new List<string>();
foreach (var allowedValue in fieldDefinition.AllowedValues)
{
allowedValues.Add(allowedValue.ToString());
}
WorkItemFieldsInfo workItemFieldInfo = workItemFieldsInfo.Find(st => st.Type == workitemType);
if (workItemFieldInfo == null)
{
workItemFieldsInfo.Add(new WorkItemFieldsInfo()
{
Type = workitemType,
AllowedValues = allowedValues
});
}
else
{
List<string> unionFields = workItemFieldInfo.AllowedValues.Union(allowedValues).ToList();
workItemFieldInfo.AllowedValues = unionFields;
}
break;
}
}
}
}
Upvotes: 0
Views: 89
Reputation: 30363
I cannot reproduce this issue. I used below rest api and it worked all fine. See here.
You can get the processid using below rest api
GET https://dev.azure.com/{organization}/_apis/work/processes?api-version=6.1-preview.2
Upvotes: 0