简体   繁体   English

如何在TFS中的工作项目上更改“创建者”字段?

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

Is there a way to change the Created By field on a work item in TFS? 有没有办法在TFS中的工作项目上更改“创建者”字段? Maybe by altering the database? 也许通过更改数据库?

I want to be able to create a bug/feature/PBI, then change it to be created by the member of staff who reported it to me. 我希望能够创建一个错误/功能/ PBI,然后将其更改为由向我报告该错误的工作人员创建。

This way, I can track who is submitted change requests, and they would also then receive bug update notifications. 这样,我可以跟踪向谁提交了更改请求,然后他们还将收到错误更新通知。

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 参考名称= Microsoft.VSTS.Common.CreatedBy

There is no build-in way to change this filed. 没有内置方法可以更改此字段。 Take a look at this: 看看这个:

IsEditable IsEditable

No 没有

Indicates if users can modify this field (True) or not (False). 指示用户是否可以(True)修改该字段(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. 不可编辑字段的示例是系统设置的字段,例如ID,Revision, Created By和Changed By字段。

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. 注意: 此功能可从TFS 2017及更高版本获得。

You can only overwrite the CreatedBy field when create the workitem via API with bypass rule enabled. 仅当在启用旁路规则的情况下通过API创建工作项时,才能覆盖CreatedBy字段。 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. 一个快速的解决方案是创建一个powershell脚本,以通过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

Why do you want to update the system field? 为什么要更新系统字段? You may add a new field "Initiator"( Add or modify a field to track work ). 您可以添加一个新字段“ Initiator”( 添加或修改一个字段以跟踪工作 )。 Set value from Created By on creation. 在创建时从“创建者”设置值。 Then update it when you want. 然后在需要时进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM