Get Workflow using code
| ||||||||
| |||
The command witexport works very well...
but, i need to get the workflow using code.
I′ve been using "Microsoft.TeamFoundation" dlls ...
but Ip havent find the way to do this..
Thanks
| ||||||||
| |||
The command witexport works very well...
but, i need to get the workflow using code.
I′ve been using "Microsoft.TeamFoundation" dlls ...
but Ip havent find the way to do this..
Thanks
Hi jalekz,
1. You can download "Process templates" which your team project use. (Team ->Team Foundation Server Settings -> Process Template Manager)
2. Open the work item xml file which you want to get workflow using code. For example task.xml which under the folder (....\[your prcess templates name]\WorkItem Tracking\TypeDefinitions).
3. Edit this xml file, the code in <WORKFLOW></WORKFLOW> is you want.
4. You can define your own workflow in this section.
Thanks,
Ed
But this is my scenario..
I have an application, I want to save Workitems to TFS from this application...
So I want to show user, the posible values of each Field..
Every field may has a list of allowed values. But in the case of State and Reason, the list of allowed values is dynamic, because the possible states and reasons deppends on previous state.
An i want to validate this... for example.
I have a new workitem. I render its fields in the screen, for the "state" and "reason" fields I add two combobox , as the workitem is new. the combo box state must have just the "Active" option and the combobox reason must have the "New" option..
When i press the buttons Save, this workitem is saved in TFS, and now the allowed values for state and reason must change. anh the options in both combobox also must change.
Thats the reason for I want to know the workflow for a WorkItemType.
I′ve tried using code like this. But I havent find an option to know the Workflow.
Project project = TFSServices.GetProject(89);
WorkItemType wit = project.WorkItemTypes["Requirement"];
FieldDefinition fstate = wit.FieldDefinitions["State"];
FieldDefinition freason = wit.FieldDefinitions["Reason"];
WorkItem w = wit.NewWorkItem();
w.Title = "Title from Test Application";
w.Save();
Thanks...
Oh, i see. As i know the workflow only allows people defined in workitem's template.
May be you can define this in the <WORKFLOW></WORKFLOW> in your work item template.
For example:
--
<WORKFLOW>
<STATES>
<STATE value="Active">
<FIELDS>
<FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
<EMPTY />
</FIELD>
</FIELDS>
</STATE>
</STATES>
<TRANSITIONS>
<TRANSITION from="" to="Active">
<REASONS>
<DEFAULTREASON value="New" />
<REASON value="Build Failure" />
</REASONS>
</TRANSITION>
</TRANSITIONS>
</WORKFLOW>
--
This section means the field "REASONS" isn't contains any values (<EMPTY/>) when you new a work item, after you save this work item and then the value of "STATE" will be changed from " " to "Active", and then the field "REASONS" will be changed to contains the values you defined in <FIELDS></FIELDS> section.