You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求协助创建VSTS查询:识别迭代不一致的PBI与任务

Got it, let's tackle this problem—identifying PBIs where at least one of their child tasks lives in a different sprint than the parent PBI itself. This is such a common pain point for larger teams that shuffle tasks across iterations, so I’ve got two straightforward ways to build this query for you.

方法1:用Azure DevOps可视化查询编辑器设置

This is great if you prefer point-and-click setup without writing code:

  1. 登录你的Azure DevOps项目, 导航到 Boards > Queries.
  2. 点击 New Query 并选择 Flat query(这种方式会直接列出符合条件的PBIs,无需展开子任务)。
  3. 添加第一个筛选条件:
    • 字段:Work Item Type
    • 运算符:=
    • 值:Product Backlog Item
  4. 添加关联工作项筛选组来检查子任务:
    • 点击 Add criteria > Linked work items
    • 选择链接类型:Child(因为我们要找PBI下的子任务)
    • 勾选 Match linked work items using the following criteria
    • 在这个子筛选组里添加:
      • 字段:Iteration Path
      • 运算符:<>
      • 值:@ThisWorkItem Iteration Path(这个宏会引用当前PBI的迭代路径,和子任务的迭代路径做对比)
  5. (可选)如果要排除已完成的PBIs,再添加一行筛选:
    • 字段:State
    • 运算符:<>
    • 值:Done(或者你团队定义的完成状态)
  6. 点击 Run query——结果就是所有存在至少一个子任务迭代与自身不一致的PBIs。
方法2:使用WIQL(工作项查询语言)

如果你更喜欢直接编写查询语句,可以用以下WIQL代码:

SELECT
    [System.Id],
    [System.Title],
    [System.IterationPath],
    [System.State]
FROM workitems
WHERE
    [System.WorkItemType] = 'Product Backlog Item'
    AND EXISTS (
        SELECT *
        FROM workitems
        WHERE
            [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
            AND [System.IterationPath] <> [Source].[System.IterationPath]
            AND [System.WorkItemType] = 'Task' -- 可选:仅筛选任务,排除Bug等其他子工作项
    )
    AND [System.State] <> 'Done' -- 可选:排除已完成的PBIs
ORDER BY [System.Id]

使用方法:

  • 在查询编辑器中,点击 ... > Edit as WIQL(或者进入 View > Query Editor)
  • 清空现有代码,粘贴上面的WIQL,然后点击 Run 即可。

小提示

  • 如果你的团队除了Task还有其他子工作项类型(比如Bug),且你想把这些也纳入检查,只需删除WIQL中的[System.WorkItemType] = 'Task'行,或者在可视化编辑器中添加OR条件。
  • @ThisWorkItem Iteration Path宏是核心——它确保我们始终在对比子任务和其父PBI的迭代路径,而不是某个固定的迭代。

内容的提问来源于stack exchange,提问作者Jan Svendsen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:49:54