Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira automation differentiate mentioned user from comment

Damian de Vries
Contributor
October 28, 2022

For our new Jira project we need to be able to add a mentioned user in a comment to the collaborators field.

I have tried to use different smart values but I wasn't able to differentiate a mentioned user from a comment.

Is there a way to differentiate usernames/accountId's from a comment?

3 answers

1 accepted

4 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2022

Hi @Damian de Vries 

You note having tried a few things, so perhaps it would help to post an image of your rule and the audit log details.  That will provide context for the community to offer ideas.  Thanks!

Writing automation rules often require experimentation to learn how things like mentions work in Jira. 

For example, try writing the last comment's body to the audit log with {{issue.comments.last.body}} and you will see how mentions are implemented as text.  That information will help you to create a regular expression to extract each of the mentioned users accountId values using the match() function, and then add them as collaborators.

Kind regards,
Bill

Damian de Vries
Contributor
October 31, 2022

Hi @Bill Sheboy ,

Thanks for your help, I managed to find a post which also managed a similar question. I saw that you commented there as well and managed to do something with the combined information.

As of now I managed to create something like this:

JiraAutomationRule.png

With this automation I can add a single user to the collaborator's field based on a users split accountId.

The problem I'm facing now is that I also want to be able to add multiple mentioned users to the collaborators field, but when I do that now only the first mentioned user gets their accountId split and the second users keeps their accountId in tact. Here is a little example:

CommentTest.pngAuditLogJiraAutomation.png

I hope you can help me out with this problem, it would be greatly appreciated!

Damian de Vries
Contributor
October 31, 2022

I just did a test where I separate the users with a bit of text and in that instance the accountId does get split but it won't add the users to the Collaborators field, I think because of the field seeing the 2 id's as one 1 id.

JiraAutomationComment2.pngJiraAutomationAuditLog2.png

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2022

The match() can return multiple values, and so if you try that as the source for an advanced branch, you can loop over the values to add each one as the Issue Edit action would be inside of the loop:

  • advanced branch: on the match() results
    • action: edit issue to add each collaborator, one by one
Damian de Vries
Contributor
November 1, 2022

Hi @Bill Sheboy ,

Thanks for your insight.

I finally managed to get the automation to work by creating a loop with the advanced branch on the Match() smart value.

Use case:
When a Jira user gets mentioned in a comment, we want the user to be added to the Collaborators field (without removing any present Collaborators).

 

Jira automation screenshot:
JiraAutomationCollaborators.png

Automation JSON:

Jira-Add-Collaborator-On-Mention-Automation 

Like # people like this
Brock Jolet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2023

@Damian de Vries Thank you for sharing the JSON, this worked great for adding users to the Request participants field.

Like Damian de Vries likes this
0 votes
Wojciech Książka
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 19, 2023

Hi,

I'm trying to get user ID when the user is mentioned - to be able to use it in automation and send additional info to the same user - but with no luck.

and I'm using: {{comment.substringBetween("[~accountid:","]")}}

automation end with success but returns no value :-(

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 19, 2023

Hi @Wojciech Książka 

Comments have several attributes, and you may want to use the body of the specific comment you need, last, first, etc. as described here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.comments--

And I recommend writing the comment value to the audit log first to help confirm your text function is extracting what you need.

Kind regards,
Bill

0 votes
David Berclaz _Apwide_
Community Champion
October 28, 2022

Hi @Dam

Recently I read this article about auto-linking an issue mentioned in a comment.
I hope it can give you some ideas on how to parse the comment and get the username or account id, even though the regex should be quite different...

Good luck!
Cheers,

David

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events