How can I prohibit State change from Proposed to Active in TFS Requirement work-item based on value of another field?

£可爱£侵袭症+ 提交于 2019-12-06 03:25:28

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.

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:

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.

Or

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!