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

后端 未结 3 824
心在旅途
心在旅途 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
    

提交回复
热议问题