如何在VSTS/TFS中设置自定义状态触发迭代自动分配规则?
Got it, let's break down exactly how to set up this automated behavior for your User Stories in VSTS/TFS—you want the item to get assigned to a specific iteration only the first time it moves from "New" to "Approved" (or other active states), and let manual changes override it later. Here are two reliable ways to make this happen:
1. 优先使用内置工作项规则(最简单的方法)
This is the go-to option since it's built right into Azure DevOps/VSTS/TFS, no code needed:
- Head to your project settings, navigate to Boards > Process, then select the process your User Story uses (like Agile or Scrum).
- Open the User Story work item type, go to the Rules tab, and click New rule.
- Configure the rule with these conditions:
- When: State changes from New to Approved (add additional state targets here if you need other active columns, e.g., "In Progress")
- And: Iteration Path is Empty (this ensures the rule only runs the first time—once the iteration is set manually or via the rule, it won't trigger again)
- Set the action to Set field value, pick Iteration Path, and select your target iteration from the dropdown.
- Save the rule, and you're done!
Any time a User Story moves from New to your target active states for the first time, it'll auto-populate the iteration you specified. If you later reassign it to a different iteration, future state changes won't overwrite that manual choice.
2. 备选:Power Automate(用于更复杂逻辑)
If you need extra conditions beyond what the built-in rules support (like checking other fields), use Power Automate:
- Create a new flow, choose the When a work item is updated trigger from the Azure DevOps connector.
- Add a Condition action with these checks:
- Work Item Type equals User Story
- Previous State equals New
- Current State equals Approved (or your other active states)
- Iteration Path is empty
- If the condition passes, add an Update work item action, set the Iteration Path to your target value.
- Save the flow, and it'll run automatically whenever the criteria are met.
Key Notes
- The built-in rule method is faster and easier for basic use cases—stick with that unless you need custom logic.
- Both methods respect the "only first time" requirement because they check if the Iteration Path is empty before triggering.
内容的提问来源于stack exchange,提问作者Phillip McMullen




