如何在TFS需求工作项中根据另一个字段的值禁止将状态从“提议"更改为“活动"? [英] How can I prohibit State change from Proposed to Active in TFS Requirement work-item based on value of another field?

查看:175
本文介绍了如何在TFS需求工作项中根据另一个字段的值禁止将状态从“提议"更改为“活动"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将部门批准添加到标准CMMI-Template Requirement工作项目中.我想限制System.State字段,以便仅当所有部门的批准都设置为是"时,才可以将其从建议更改为活动.

I've added department approvals to the standard CMMI-Template Requirement work-item. I'd like to limit the System.State field such that it can only be changed from Proposed to Active when all department approvals are set to "Yes".

我尝试了对Requirement.xml的以下更改

I've tried the following change to Requirement.xml

<FIELD name="State" refname="System.State" type="String" reportable="dimension">
  <WHEN field="Approval.Marketing" value="No">
    <READONLY />
  </WHEN>
  <WHEN field="Approval.Quality" value="No">
    <READONLY />
  </WHEN>
  <WHEN field="Approval.RD" value="No">
    <READONLY />
   </WHEN>
   <WHEN field="Approval.System" value="No">
     <READONLY />
   </WHEN>
   <WHEN field="Approval.ProgManagement" value="No">
     <READONLY />
   </WHEN>
</FIELD>

如果将任何批准字段设置为否",这将导致状态"字段变为只读"状态.但是,这在创建新需求时会引起问题,因为最初的批准都是否",因此由于READONLY条件,未设置State的初始提议"默认值.我想做的就是在上述WHEN条件中添加逻辑,以使用条件System.State ="Proposed" AND 对它们进行.我尝试嵌套WHEN子句,例如

This causes the State field to become READONLY if any of the approval fields are set to "No" which is what I want. However it causes problems when creating a new requirement since the approvals are all "No" initially and thus the initial "Proposed" default for State doesn't get set due to READONLY condition. What I'd like is to do is add logic to the WHEN conditions above to AND them with the condition System.State="Proposed". I tried nesting WHEN clauses such as

<FIELD name="State" refname="System.State" type="String" reportable="dimension">
  <WHEN field="System.State" value="Proposed">
    <WHEN field="Approval.Marketing" value="No">
      <READONLY />
    </WHEN>
         . . .
  </WHEN>
</FIELD>

但这会导致导入错误, WHEN 子句不能包含 WHEN .当任何批准"字段设置为否"时,如何禁止状态从建议更改为有效

But this gets an error on import that WHEN clause cannot contain WHEN. How can I prohibit State change from Proposed to Active when any of the Approval fields are set to "No"

推荐答案

我花了一些时间来弄清楚是否可以提出可行的变体,因为您无法以可能的方式为System.State设置默认值其他领域.在提出可行的方法之前,我可能经历了大约50种变化.当然,这不是理想的方法,但是在最初创建后就可以解决您的问题.

I spent some time figuring out if I could come up with a variation that would work since you cannot set a default value for System.State in the way you can other fields. I probably went through 50 or so variations before I came up with something that works. Granted, it is not ideal but it would solve your problem after the initial creation.

您可以在每个过渡状态内添加when子句.对于我的示例,我使用优先级字段并执行以下操作:

You could, inside each of the transition states, add your when clauses. For my example I was using the priority field and doing something like:

<State value="Proposed">
  <FIELDS>
    <FIELD refname="Microsoft.VSTS.Common.ResolvedDate">
      <EMPTY />
    </FIELD>
    ...
    <FIELD refname="System.State">
      <WHEN field="Microsoft.VSTS.Common.Priority" value="2">
        <READONLY />
      </WHEN>
    </FIELD>
  </FIELDS>
</State>

您必须将子句添加到其他状态:活动,关闭和已解决.

You would have to add your clauses of course to the other states: active, closed and Resolved.

完成后,创建一个新的需求.创建新需求时,有两个选择:

Once you do that, create a new Requirement. When you create a new requirement you have two options:

您可以将所有选项设置为是",将状态设置为建议"并保存.然后返回并设置为no并保存.

You can either set all the options to yes, set state to proposed and save. Then go back and set them to no and save.

将所有自定义字段更改为默认为是". 创建需求并保存.编辑它,将所有值切换为no,保存.

Change your custom fields all to default to yes. Create Requirement and save. Edit it, switch all the values to no, Save.

无论哪种选择,一旦最初的障碍随着需求创建而结束.它会按照您想要的方式运行.换句话说,如果任何一个值都不是,那么它将使状态变为只读.

Either way you choose to go, once this initial hurdle is over with the requirement creation. It will act how you wanted it to. In other words, if any of the values are no then it will make state readonly.

鉴于对System.State字段的限制,这是我能想到的最好的方法.

That was the best I could come up with given the restriction for the System.State field.

这篇关于如何在TFS需求工作项中根据另一个字段的值禁止将状态从“提议"更改为“活动"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆