Thursday, December 22, 2011

Adding custom field to Work Item Tracking Template "Task"

1) I would assume that you already have the template open or know how to open it from the server for type "Task" in project "SharePoint.Samples" (follow instruction on top to open the template)
2) We would add a drop-down with options and make this field mandatory
3) Switch to tab "Fields" and click "Add"
4) We are naming the new Field as "Solution Type" in tab "Field Definition" enter the detail as highlighted in the image below (Name : Solution Type | Type : String | RefName : SharePoint.Samples.Task.SolutionType | Reportable : dimension )

5) How do we make it a drop-down? Now change the tab to "Rules"
6) Click on "Add" and new window "Select a rule type" will popup
7) Select "ALLOWEDVALUES" which should be the first in list and click "OK"

8) In window "ALLOWEDVALUES" click on "Add"
9) In window "List Item Edit" add the value "Web Part" in "List Item" on click "OK"

10) Repeat two step above to add the following values "Page Layout", "Master Page", "Content Type", "Custom Lists"
11) When you have added all the value in window "ALLOWEDVALUES" click "OK"

12) Click "OK" in window "Field Definition"

13) Now we need to add this field to the form (UI) so that people can start using it
14) Switch to the tab "Layout" and locate "Group - Classification" underneath this right click on "Column" and click on "New Control"

15) Now edit the properties of control form the properties pane on right side of window
16) Change the property for "FieldName" and select "SharePoint.Samples.Task.Solution.Type" from the drop down (this it the custom field which we just created)

17) Change the property "Label" to "Solution Type"
18) Leave all other property values to default for this control

19) Now we have to make this value as Required (Mandatory) while new Task is created
20) Switch to tab "Workflow"
21) Right click on "Transition" (first blue box) and click on "Open Details"

22) In window "Workflow Transition" switch to tab "Fields" and click on "Add"
23) In window "Field Reference" select value for "RefName:"
24) Select "SharePoint.Samples.Task.SolutionType" from drop down and click "OK"

25) In window "Field Reference" switch to tab "Rules" and click on "Add"
26) In window "Select a rule type" select "REQUIRED" and click on "OK"

27) In window "REQUIRED" click on "OK"

28) In window "Field Reference" press "OK"

29) In window "Workflow Transition" click on "OK"

30)Now save the changes to template by "Ctrl+S"
31) After saving the changes refresh the project from Team Explorer, wait for some time after refresh and try to refresh couple of times and have some wait time between the refresh.
32) Open "Team Explorer" > Right click on the Project "SharePoint.Samples" > "Refresh"

33) To verify the changes now you should create a new task
34) Open "Team Explorer" > Expand the project "SharePoint.Samples" > Right click "Work Items" > "Add Work Item" > "Task"

35) Once the new task form is open, you should see your changes as per the image below, the filed is highlighted in yellow which denotes that this is required in order to create a new task

We are done!!

But what if we want to do this for all existing projects? Simple, we do export and import.
1) From VS Menu click "Team" > "Process Editor" > "Work Item Types" > "Export WIT"

2) Enter your server details and press "Connect"

3) You will now see all the projects in TFS, Select the Project and then expand it to select the work item type you want to export "Task" for this post and click "OK"

4) You will see the "Save As" window, browse to the location where you want to save, name the file and click "Save"

5) If you get popup window "Global List" asking "Would you like to include the Global List Definition?" click on "NO"

6) From VS Menu click "Team" > "Process Editor" > "Work Item Types" > "Import WIT"

7) In window "Import Work Item Type Definition"
8) Click on "Browse..." and locate the file which you saved earlier during "Export WIT"
9) Select the project to which you want to apply this template "CustomerService"
10) Click on "OK"

Its done, now to verify do as we did couple of time before, refresh the project "CustomerService" and then create the new task. You should see your changes applied.

for more information please read the given link read...

No comments: