How to change the Created By field on a Work Item in TFS?

后端 未结 3 825
心在旅途
心在旅途 2021-01-28 01:27

Is there a way to change the Created By field on a work item in TFS? Maybe by altering the database?

I want to be able to create a bug/feature/PBI, then change it to be

相关标签:
3条回答
  • 2021-01-28 02:17

    You can only overwrite the CreatedBy field when create the workitem via API with bypass rule enabled. Refer to this link for details: Make an update bypassing rules.

    A quick solution for this would be create a powershell script to create the workitem via Rest API. Sample for your reference:

    #Input basic information
    $collectionuri = "http://tfsserver:8080/tfs/DefaultCollection/"
    $project = "ProjectName"
    $workitemtype = 'Task'
    $createdby = 'Display Name'
    $title = 'Title'
    
    #Create the workitem
    $workitem = @(@{op="add";path="/fields/System.Title";value=$title},@{op="add";path="/fields/System.CreatedBy";value=$createdby})
    $json = $workitem | ConvertTo-Json -Depth 100
    $headers= @{"Content-Type"="application/json-patch+json"}
    $url= $collectionuri + $project + '/_apis/wit/workitems/$' + $workitemtype +'?bypassRules=true&api-version=1.0'
    $mycredentials = Get-Credential
    $wi = Invoke-RestMethod -Uri $url -Method Patch -Credential $mycredentials -Body $json -ContentType 'application/json-patch+json' 
    Write-Host $wi
    
    0 讨论(0)
  • 2021-01-28 02:18

    Why do you want to update the system field? You may add a new field "Initiator"(Add or modify a field to track work). Set value from Created By on creation. Then update it when you want.

    0 讨论(0)
  • 2021-01-28 02:20

    Seems you want to set a faker creator for a work item.

    Created By

    The name of the team member who created the work item.

    Reference name=Microsoft.VSTS.Common.CreatedBy

    There is no build-in way to change this filed. Take a look at this:

    IsEditable

    No

    Indicates if users can modify this field (True) or not (False). Examples of non-editable fields are ones that are set by the system, such as the ID, Revision, Created By, and Changed By fields.

    More details please refer Work Item Field Attributes – What You Can and Can’t Change

    Change the value directly in the Database may do the trick, but it's not a recommend way. It's also go against the concept of source control.

    If you just want to notify others when work item update. As a workaround, suggest you use the follow function in work item.

    When you want to track the progress of a single work item, click the Follow icon icon. This signals the system to notify you when changes are made to the work item.

    Note: This feature is available from TFS 2017 and above.

    0 讨论(0)
提交回复
热议问题