Workflow of WorkItem
Workflow consists of States and Transitions.
A workflow has multiple states, such as Active and Closed. Following code shows a state sample:
<State value="Active"> <FIELDS> <FIELD refname="Microsoft.VSTS.Common.ClosedDate"> <EMPTY /> </FIELD> <FIELD refname="Microsoft.VSTS.Common.ClosedBy"> <EMPTY /> </FIELD> </FIELDS> </State>
The field used in <Fields> means that when state of workitem was changed to “Active ”, the value of "Microsoft.VSTS.Common.ClosedDate" and ="Microsoft.VSTS.Common.ClosedBy" are set to empty.
There are transitions between states. Following code shows a transition sample:
<Transition from="Closed" to="Active"> <REASONS> <DEFAULTREASON value="Reactivated" /> </REASONS> <FIELDS> <FIELD refname="Microsoft.VSTS.Common.ActivatedBy"> <COPY from="currentuser" /> <VALIDUSER /> <REQUIRED /> </FIELD> <FIELD refname="Microsoft.VSTS.Common.ActivatedDate"> <SERVERDEFAULT from="clock" /> </FIELD> <FIELD refname="System.AssignedTo"> <COPY from="field" field="Microsoft.VSTS.Common.ClosedBy" /> </FIELD> </FIELDS> </Transition>
Each transition has a direction, such as “From Close to Active” or “From Active to Close”. The direction means that the state can be changed to another, if there is no transition whose direction is from StateA to another StateB, “StateB” will not appear in State DropdownList in WorkItemEditUI.
When a workitem is created, the initial state is “”, so there should be at least one transition whose “from” is “”.
You can add some reasons why the transition starts so that user can select one in WorkItemEditUI, the default value is set in <DEFAULTREASON>
Like <Fields> defined in State, The field used in <Fields> means that when the transition start, the value of "ActivatedBy" is set to current user , the value of "ActivatedDate" is current moment and the value of “ClosedBy” is copied from “ClosedBy”.
Some transitions also include a node named <Actions> like
<TRANSITION from="Working" to="Ready To Build"> <ACTIONS> <ACTION value="microsoft.vsts.actions.checkin"/> </ACTIONS> </TRANSITION>
An chek-in action can be associated to a workitem. So it means that when a check-in action occured, the transition will start.