In my previous post of TFS work item customization using TFS power tool, I have explained how to customize Task work item template to add new custom fields named “Tech Decision” and “Management Decision” with drop down values Approved, On-Hold and Rejected.
In this post we will see how to add some validation rules for the fields "Tech Decision" and "Management Decision".
Consider a scenario where the “Tech Decision” field should only be selected by developers, and “Management Decision” can only be selected by Managers.
Right now in our custom template these field values can be selected by any of the team project members, but if
we want to restrict the fields to some set of users or groups we can make use of a rule “Read Only” for the field in such a way that the field is editable
only for particular group.
To achieve this let's create a new group named Managers for managers and for
developers we will use default group Contributors, considering all developers are added to the group Contributors and managers to Management group.
To create group for the team project connect to team project using browser and then click on Manage Project gear link at the top right. This will open Team Project admin page.
Click on Security. Now in the Security page of Team Project Click on Create TFS Group link to create the new group.
You can also give some optional description for this group. Then click on Create group button.
Give Permissions as below (which can be modified later), here we will give minimum permission by setting the permission "View project-level information = Allow", please find below screenshot for your reference.
By above permission the users of this group just be able to view the team project, but will not be able to create work item. To give create work item permission for “Managers” group we need to add the group into the team project “Areas” security list and give
appropriate permission. To do this, Click on Areas tab and click on small drop down button highlighted in the below screenshot.
Then click on Security option in the drop down.
Click on Add and select Add TFS group to add the new group Managers.
Now select Managers group and then click “Save changes”.
Now select the newly added group Managers and edit permission at the right side as shown in below screen. This is the minimum permission required to view and edit work items in this area node.
Close the window and close the browser. This completes creation of new group and setting permission for the group.
Now let us modify the Task work item template to add the condition for the field so that only members of Managers group can edit values of “Management Decision” and members of Contributors group only can select values of Tec Decision.
In the last blog we would have
seen how to export the work item template from server and edit. In this blog we
will see how we can directly edit work item on server.
Open Visual Studio, and Click on TOOLS -> Process Editor-> Work Item
Types-> Open WIT from server, to open the template online.
Now connect to the TFS and then
to the Team Project under the Team Project Collection. Select work item type
Task which was customized earlier.
In the fields tab, double click on “Tech Decision” field.
In the Field Definition window click on Rules tab and then click New, select a rule type READONLY then click OK
Now in the READOLY window set value for “Not” text box to [project\Contributors] as shown in below screenshot.
Click OK then OK.
What this condition does is, the field Tech Decision will be
editable only for members of the Contributors group and for others it is READONLY (non-editable).
Let’s follow the same steps for “Management Decision” field.
Similarly double click on “Management Decision” field. In the Field Definition
window click on Rules tab and then click
New, select a rule type READONLY then click OK.
Now in the READOLY window set value for “Not” text box to [project\Managers] as shown in below screenshot.
Click OK then OK.
Save all changes by clicking on Visual Studio save button or
Ctrl+S. Since we are editing work item directly in sever, we can connect to the
respective team project and validate the update we have done.
Now connect to TFS using account which is member of Managers or Contributors group you will see both fields are non-editable. Also
try connecting to the Team project using account which is member of
Contributors group but not of Managers
group, you can find the field “Management Decision” is non-editable for the
user. Same way try connecting to team project using account which is member of Managers group but not of Contributors group you can find that
the user will not be able to edit “Tech Decision” field.
Hope this blog was useful. We will see few more customization
options in coming blogs.
No comments:
Write comments