Search code examples
tfstfs-process-template

TFS Work Item type - Access to field based on rights



I have work item type template where i want to assign right to change drop down list to default value as "Requested" for new item and every one can see and read it. If user is in group "[TEAM FOUNDATION]\Approvers" or "[TEAM FOUNDATION]\Developers" they are able to change this item.

I have a problem if user is not in either of the groups it will fail and blank display disabled field. How do i define these permissions?

My definition of field is below.

<FIELD name="Approval" refname="Approval" type="String" reportable="dimension">
    <REQUIRED />
    <DEFAULT from="value" value="Requested" />
    <ALLOWEDVALUES>
      <LISTITEM value="Approved" />
      <LISTITEM value="Requested" />
      <LISTITEM value="Rejected" />
    </ALLOWEDVALUES>        
    <DEFAULT from="value" value="Requested" />
    <READONLY not="[TEAM FOUNDATION]\Approvers" />
    <READONLY not="[TEAM FOUNDATION]\Developers" />
    <HELPTEXT>Shows whether the task has been approved by management.</HELPTEXT>
  </FIELD>

Solution

  • This seems like a heavy one.What is your exact intend? Maybe using a WHEN block or splitting the restrictions into basic ones (at the field definition) and special ones at state or transition level will solve your problem?

    <FIELD name="Approval" refname="Approval" type="String" reportable="dimension">
        <REQUIRED />
        <DEFAULT from="value" value="Requested" />
        <WHENNOT field="System.State" value="New">
          <READONLY not="[TEAM FOUNDATION]\Developers"/>
          <READONLY not="[TEAM FOUNDATION]\Approvers"/>
        </WHENNOT>
        <HELPTEXT>Shows whether the task has been approved by management.</HELPTEXT>
    </FIELD>
    

    or

    <FIELD name="Approval" refname="Approval" type="String" reportable="dimension">
        <REQUIRED />
        <ALLOWEDVALUES>
          <LISTITEM value="Approved" />
          <LISTITEM value="Requested" />
          <LISTITEM value="Rejected" />
        </ALLOWEDVALUES>        
        <DEFAULT from="value" value="Requested" />
        <HELPTEXT>Shows whether the task has been approved by management.</HELPTEXT>
    </FIELD>
    
    <TRANSITION from="" to="New">
        <FIELDS>
            <FIELD refname="Approval">
                <READONLY not="[TEAM FOUNDATION]\Developers"/>
                <READONLY not="[TEAM FOUNDATION]\Approvers"/>
            </FIELD>
    </TRANSITION>
    

    By the way: You should refName your fields with a whole "Namespace", e.g. "My.Company.TfsFields.Common.Approval" or "My.Company.TfsFields.Bugs.IsRegression"