TFS Api not giving custom states in a customized Process Template on Dev Azure

88 views Asked by At

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.

enter image description here

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;
                        }
                    }
                }
            }
1

There are 1 answers

3
Levi Lu-MSFT On