0

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();
    }
}
  • I should add that the text added to the discussion appears to be added just as though it was added on TFS web, character for character and while the discussion looks as though TFS had added the mention natively, it still does not send emails. – thisisntjared Sep 10 '18 at 19:04
  • Do you mean that the @mention works on @ user, but the users cannot receive notifications? If it is, please check if this thread helps : https://stackoverflow.com/questions/47628907/how-to-make-vsts-email-me-if-somebody-mention-me-on-discussion – Andy Li-MSFT Sep 11 '18 at 05:50
  • @AndyLi-MSFT More to the point: when a service account adds the above mention, the users does not get the notification, but when I call the very same REST API call to update the history, users get notifications. the resulting history is the same no matter which account runs it, but the service account will fail to send emails. I am updating the initial post with this. – thisisntjared Sep 11 '18 at 15:47

1 Answers1

0

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

  • You could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), This can be beneficial to other community members reading this thread. – Andy Li-MSFT Sep 17 '18 at 06:13