TFS Process Template XML - Set default System.History value - tfs

I would like to add a custom rule to set a default History when changing the status.
<FIELD name="History" refname="System.History" type="History">
<HELPTEXT>Discussion thread plus automatic record of changes</HELPTEXT>
<WHENCHANGED field="System.State">
<DEFAULT from="value" value="State changed" />
</WHENCHANGED>
</FIELD>
getting below error.
**Error importing work item type definition:
TF26062: Rule '<DEFAULT from="value" value="State changed" />' is not supported for the field 'System.History'.**
any help would be appreciated.

Checking the Process xml file, you would like to add a value for the Discussion field when the status of this work item changes.
Discussion field of the work item is not supported to use custom rule to set a value when changing status.
You could consider create a new custom field to apply your rule.

Related

Validate TFS 2017 Boolean field

I am trying to edit work item templates to make use of the new Boolean field in TFS 2017, and want a particular field to be set to true before a status can be changed. Is there any way to do this? It would appear ALLOWEDVALUES and MATCH aren't supported, which could have potentially helped
You can do that by applying a conditional rule based on your requirement just as Hamid mentioned above.
Boolean is just a data type, we can add a custom Boolean field and add a checkbox for it.
Use the following syntax to add a Boolean field within the FIELDS
section of the WIT definition.
<FIELD name="Triagelc" refname="lc.Triage" type="Boolean" >
<DEFAULT from="value" value="True" />
<HELPTEXT>Triage work item</HELPTEXT>
</FIELD>
And then add the following syntax within the FORM section to have
the field appear on the form.
<Control Label="Triagelc" Type="FieldControl" FieldName="lc.Triage" />
The field will appear as a checkbox on the form.
Then apply a When rule for target filed, thus when the specified
Boolean field has the specified value, the When rule is applied to
the target field.
eg1:
Apply a "When" rule for Description field in Task work item type :
<FieldDefinition name="Description" refname="System.Description" type="HTML">
<WHEN field="lc.Triage" value="True">
<REQUIRED />
</WHEN>
</FieldDefinition>
Then when set the value to True, the Description area is required, it cannot be empty.
eg2:
You can also use READONLY rule to restrict other areas:
<FieldDefinition name="Assigned To" refname="System.AssignedTo" type="String" syncnamechanges="true" reportable="dimension">
<WHEN field="lc.Triage" value="True">
<READONLY />
</WHEN>
<ALLOWEXISTINGVALUE />
<HELPTEXT>The person currently owning this task</HELPTEXT>
</FieldDefinition>
Thus, when the Boolean field value is True, Assigned To field is read only, otherwise you can assign to the existing users.
UPDATE:
eg3:
We can not achieve that directly with the boolean data type. As a workaround you can try below ways:
Apply the When rule and embed the Copy rule (Copy True as the
value) for the "Triagelc" boolean field in this example. Thus when
the status is Done, Triagelc can set the value to "True"
automatically, then save. But in this way the value still can be
modified to false. Reference below screenshot 1:
<FieldDefinition name="Triagelc" refname="lc.Triage" type="Boolean">
<WHEN field="System.State" value="Done">
<COPY from="value" value="True" />
</WHEN>
<HELPTEXT>Triage work item</HELPTEXT>
</FieldDefinition>
Set the default value to True for Boolean field (Triagelc
field in this example), then apply When rule with READONLY rule
embedded. This way should be meet your requirement (Once done the value cannot be changed anymore). Reference below screenshot 2:
<FieldDefinition name="Triagelc" refname="lc.Triage" type="Boolean">
<DEFAULT from="value" value="True" />
<WHEN field="System.State" value="Done">
<READONLY />
</WHEN>
<HELPTEXT>Triage work item</HELPTEXT>
</FieldDefinition>
Please note that:
The Boolean data type field is only supported for VSTS and TFS 2017.2
and later versions.
Screenshot 1:
Screenshot 2:

TFS. How to set <required changes> field if value has been already set?

I have some custom field in Bug WI. I want to set it to but even if there was not NULL value after state of WI changed.
Example: Let's say I have that config in transition:
<TRANSITION from="Active" to="Resolved">
<FIELD name="Version">
<REQUIRED />
</FIELD>
</TRANSITION>
When bug change it's state from Active to Resolved first time it works (field become yellow - fill required to proceed), but after, if I change state to New, then to Active and then to Resolved, there is no request to CHANGE previous field value. I think it's need check with previous value, and if it's equal, then require from user another value. Any suggestions how to do that?
Thanks
Found a solution.
Created hidden field "TempVersion". In transition Resolved to New/Active I copy value of Version to TempVersion.
<FIELD refname="TempVersion">
<COPY from="field" field="Version" />
</FIELD>
In transition Active->Resolved added :
<TRANSITION from="Active" to="Resolved">
<FIELD name="Version">
<NOTSAMEAS field="TempVersion" />
<REQUIRED />
</FIELD>
</TRANSITION>
Seems like it works!
REQUIRED rule requires a user to specify a value for the field. Users cannot save a work item until they have assigned values to all required fields. In your scenario, as the field "Version" has been specified a value, there is no restriction.
Default work item rules can't compare values, you'll need to customize a work item control to achieve what you want. You can get start by following https://witcustomcontrols.codeplex.com/

Pre defined text in Details field in Work Item TFS 2015

we want the details field of our work items to have a pre defined text. Since the fields have the attribuded HTML, is it possible to do so?
Yes, you can customize the field to have a default value (Define a default value or copy a value to a field) and you can use html code for the default value:
<FIELD name="Repro Steps" refname="Microsoft.VSTS.TCM.ReproSteps" type="HTML">
<REQUIRED />
<DEFAULT from="value" value="<b>Environment tested:</b><br/>foo<br/><br/><b>Steps:</b><br/><ol><li>&nbsp;</li><li>&nbsp;</li></ol><br/><b>Actual results:</b><br/><br/><b>Expected results:</b><br/>" /></FIELD>

Setting TFS field as readonly based on area path

I have custom TFS form with a text field comment. I want this field to be readonly for most of the area paths except 4. How can I add condition to set the field as read only?
basically, when the area id is 1,2,3,4 the comment field should not be readonly else it should be readonly.
I tried the following, but it didn't work
<FIELD name="Comment" refname="test.test.comment" type="Integer">
<WHENNOT field="System.AreaId" value="1">
<READONLY />
</WHENNOT>
<WHENNOT field="System.AreaId" value="2">
<READONLY />
</WHENNOT>
<WHENNOT field="System.AreaId" value="3">
<READONLY />
</WHENNOT>
<WHENNOT field="System.AreaId" value="4">
<READONLY />
</WHENNOT>
</FIELD>
I dont want to write when conditions because these 4 are constant and I have about 40 other area ids which keeps increasing.
No, "And" multiple "WHENNOT" conditions doesn't work. See: Work Item state change rules in TFS - Any way to use "AND"s or "OR"s?
So, instead of using work item rules, you need to work with custom work item control. Determine when to set Comment filed to be readonly via using TFS API. Check this link for the details on how to work with custom work item control: https://witcustomcontrols.codeplex.com/

TFS 2013 Add and reffer to new link type

I would like to add proper management for Duplicated bugs.
My plans were to Add new link type "Duplicating" and to prevent move to "Duplicated" in case the new linktype ==0.
Steps Taken:
Add new link type: https://msdn.microsoft.com/en-us/library/dd273716.aspx
preventing:
<FIELD refname="My.DuplicatingBug">
<WHEN field="My.LinkType.Duplicating" value="0">
<COPY from="value" value="0" />
</WHEN>
<COPY from="value" value="Valid Completed Work time" />
<PROHIBITEDVALUES expanditems="true">
<LISTITEM value="0" />
</PROHIBITEDVALUES>
</FIELD>
Yet, when trying to import the new WIT, The following prompts:
Error importing work item type definition:
TF201000: Field reference name My.LinkType.Duplicating conflicts with an existing link type. The name is already in use.
I assume that on your bug work item definition you have defined 2 fields: My.DuplicatingBug and My.LinkType.Duplicating
When you created your custom link you probably defined it as
When you're uploading the new bug definition, the field reference is clashing with the link type reference.
I'm not 100% certain but I don't think there is a way to add a conditional value to a field based on a link type.
Could you perhaps add a new field on the Bug work item called "Duplicate Bug ID" and even a new closed state of "Duplicate" and you can only move into the Duplicate state if you have populated the "Duplicate Bug ID"

Resources