Search code examples
tfsazure-devopstfs-workitemmention

Getting @Mention to work with a TFS Extension on TFS 2017.3


I am trying to programmatically add the mention of users that are members of groups in TFS in the discussion area of work items. We were using the 1.0 version with TFS 2017 update 2 with success:

<a href=\"{id.UniqueName}\" data-vss-mention=\"version:1.0\">@{id.DisplayName}</a>

However upgrading to TFS 2017 update 3 fails to send emails on the notifications. We also tried all of the "user ids" we could find on the TeamFoundationIdentitiy object for the solutions found here: VSTS - uploading via an excel macro and getting @mentions to work

So how can we get emails for @mentions to work again in TFS 2017.3?

Update: 9/11/2018

Verified service account fails to send emails while my account running the same code will send emails for mentions:

using (var connection = new VssConnection(collectionUri, cred))
using (var client = connection.GetClient<WorkItemTrackingHttpClient>())
{
    var wi = new JsonPatchDocument
    {
        new JsonPatchOperation()
        {
            Operation = Operation.Add,
            Path = "/fields/System.History",
            Value = $"<a href=\"mailto:{id.Descriptor.Identifier}\" data-vss-mention=\"version:1.0\">@{id.DisplayName}</a>&nbsp; <br/>"
        }
    };
    using (var response = client.UpdateWorkItemAsync(wi, workItemId, suppressNotifications: false))
    {
        response.Wait();
    }
}

Solution

  • We solved by dropping use of the WorkItemHttpClient and going back to loading the SOAP WorkItemStore as the user that submitted the changes instead of the service account. It would be nice if we could use impersonation of a user with TFS's WebApi