locked
TFS Workflow - validate a field not to be cleared (no empty string allowed) RRS feed

  • Question

  • I want a WorkItem to have a field "System.Description" that must be filled  on a certain state.

    Field-Definition:

    <FIELD name="Description" refname="System.Description" type="HTML">
    	<WHEN field="System.State" value="Analyze">
    	  <REQUIRED />
    	</WHEN>
    </FIELD>
    

    also a check in the Workflow Transition:

    <TRANSITION from="Concept" to="Analyze"> <FIELDS> <FIELD refname="System.Description"> <REQUIRED /> </FIELD> </FIELDS>

    ...


    On a new item this works as desired (the fields seem to be null initial).

    BUT this validation does not work, if the field was filled and cleared afterwards (the REQUIRED error never comes again).

    It is now possible to move the item to state "Analyze" with a description value that contains nothing (empty string!?).

    How do I add this validation? 

    The description must be set and should never lose this.

    Thx,

    Andi


    Tuesday, October 13, 2015 10:31 AM

Answers

All replies

  • Hi Dgjohnson,  

    Thanks for your post.

    Try below settings, it works in my TFS 2013 Update 4 work item:

    <FieldDefinition name="Description" refname="System.Description" type="HTML">

      <WHEN field="System.State" value="Analyze">

        <REQUIRED />

      </WHEN>

    </FieldDefinition>

    <Transition from="Concept" to="Analyze">

      <REASONS>

        <DEFAULTREASON value="comment">

          <FIELDS>

            <FIELD refname="System.Description">

              <REQUIRED />

            </FIELD>

          </FIELDS>

        </DEFAULTREASON>

      </REASONS>

    </Transition>


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Wednesday, October 14, 2015 6:31 AM
    Moderator
  • Sorry John - your XML seems to be invalid.

    I get:

    The element 'REASONS' has invalid child element 'FIELDS'. List of possible elements expected: 'REASON'.
    ErrorInvalidXml
    Failed

    Andi

    Wednesday, October 14, 2015 1:43 PM
  • Hi Andi,  

    Thanks for your reply.

    What’s the version of your TFS?

    Your current team project created using which default process template?

    You edited the field in which work item type?

    Please share the detailed information here, I will try the do the settings in the same environment and share screenshots here.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Thursday, October 15, 2015 2:16 AM
    Moderator
  • Hi John,

    it is a TFS 2015, Agile Process Template, WIT User Story (Workflow adopted).
    State workflow: "New" -> "Concept" -> "Analyze" -> ...

    I am not able to set a REQUIRED rule which will also bring an error, when somebody deletes the contents of that field afterwards.

    For example: create new card, add description and move from State "Concept" to "Analyze". Then move back to State "Concept" and delete the description.
    I am now able to move the work item to "Analyze"even without a description.

    It seems that the field checks for Null which is not equal to empty string!?

    TIA, Andi 

    Thursday, October 15, 2015 5:15 AM
  • Hi Andi,  

    Thanks for your reply.

    I tested this scenario in my TFS 2015 default Agile team project, it works fine too.

    I didn’t custom the workflow in my User Story work item type(just changed name to User Story Test), so I did this example from its default workflow: “New” -> “Active” -> “Resolved”, below is the xml settings in Description field and Transition(from Active to Resolved):

    <FieldDefinition name="Description" refname="System.Description" type="HTML">

      <WHEN field="System.State" value="Resolved">

        <REQUIRED />

      </WHEN>

      <HELPTEXT>Description or reference to the story that must work for this work to be considered complete</HELPTEXT>

    </FieldDefinition>

    <Transition from="Active" to="Resolved">

      <ACTIONS>

        <ACTION value="Microsoft.VSTS.Actions.Checkin" />

      </ACTIONS>

      <REASONS>

        <DEFAULTREASON value="Code complete and unit tests pass">

          <FIELDS>

            <FIELD refname="System.Description">

              <REQUIRED />

            </FIELD>

          </FIELDS>

        </DEFAULTREASON>

      </REASONS>

      <FIELDS>

        <FIELD refname="Microsoft.VSTS.Common.ResolvedBy">

          <ALLOWEXISTINGVALUE />

          <COPY from="currentuser" />

          <VALIDUSER />

          <REQUIRED />

        </FIELD>

        <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">

          <READONLY />

        </FIELD>

        <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">

          <ALLOWEXISTINGVALUE />

          <READONLY />

        </FIELD>

        <FIELD refname="Microsoft.VSTS.Common.ResolvedDate">

          <SERVERDEFAULT from="clock" />

        </FIELD>

      </FIELDS>

    </Transition>


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Thursday, October 15, 2015 7:03 AM
    Moderator
  • Hi Andi,  

    If I change state from Active to Resolve, the warning appears, after input string in Description field, that warning disappear and I can save the work item.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Thursday, October 15, 2015 7:27 AM
    Moderator
  • Hi Andi,  

    If I empty the value in Description field, that warning appears again, and if changed the state to another value than Resolved, that warning will disappear.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Thursday, October 15, 2015 7:30 AM
    Moderator
  • Hi John,

    I got it -  this works only inside Visual Studio.

    BUT - ever tried this in WebAccess? Seems to be a bug there!
    Please tell me if you can reproduce it.

    Thank you, Andi

    Thursday, October 15, 2015 2:30 PM
  • Hi Andi,

    Thanks for your reply.

    Yes, I reproduced this scenario in Web Access and receive the same result with your description.

    For this rule works in TFS 2015 Web Access scenario, please submit it to Microsoft Connect Feedback portal at: https://connect.microsoft.com/VisualStudio. Microsoft engineers will evaluate them seriously.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Friday, October 16, 2015 5:38 AM
    Moderator
  • Thank you - John.

    I have reported a bug to Microsoft:

    https://connect.microsoft.com/VisualStudio/feedback/details/1907255/tfs-2015-webaccess-required-rule-only-checked-once-new-item

    Please vote for it, to get it fixed!

    TIA,

    Andi

    • Proposed as answer by John QiaoModerator Friday, October 16, 2015 7:48 AM
    • Marked as answer by duck42 Friday, October 16, 2015 7:49 AM
    Friday, October 16, 2015 7:36 AM