![](/img/trans.png)
[英]Programmatically add @mention for Active Directory User Account in on-prem Azure DevOps Server work item comment (Jan, 2021)
[英]Ping (@) user in Azure DevOps comment
我有下面的方法,可以在 Azure DevOps 中對工作項發表評論。
我如何在評論中@
用戶?
下面的兩個示例只是發布了一個@firstName lastName
字符串,而不是標記用戶。
pMessage = "@User you need to take a look at this workitem"
pMessage = "@firstName lastName <mail> you need to take a look at this workitem"
public async Task PingUser(List<int> pId, string pMessage, VssConnection pConnection)
{
WorkItemTrackingHttpClient client = pConnection.GetClient<WorkItemTrackingHttpClient>();
foreach (var id in pId)
{
await client.UpdateWorkItemAsync(
new JsonPatchDocument()
{new JsonPatchOperation(){
Operation = Operation.Add,
Value = pMessage,
Path = "/fields/System.History",
}}, id);
}
}
如果你執行 Get 操作,你可以看到你需要的格式:
var wi = workitemClient.GetWorkItemAsync("project", id).Result;
wi.Fields["System.History"]
值為:
所以格式是:
<a href="#" data-vss-mention="version:2.0,userid"></a>
用用戶userid
替換用戶 ID,要獲得它,您可以使用用戶權利 - 列表Rest API。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.