I want to create a rule that, for example, makes a web request when a user is mentioned in a comment and I need to get the mentioned user's accountId from the comment. How to achieve this?
Here is the answer:
To trigger an action when a comment contains (or does not) a mention you should use the following regular expression:
\[~accountid:.+\]
If you want a rule to trigger when a mention is present in a comment body, it should look like this:
If you want to extract accountId from the mention in the last comment you should use the following smart value:
{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~accountid:").remove("]")}}
For example, you can use the smart value in an email body or in a web request to Jira API.
Hi there
This isn't working for me. The automation rule audit log shows that the rule recognizes that a comment was added, but it doesn't seem to be recognizing the user mention. Could this be something to do with how our mentions are displayed? In our setup, when someone is mentioned their name is displayed in format Lastname, Firstname. We are on Jira Server v7.12.3.
Any suggestions please?
Thanks.
Hi,
I'm not sure it should work for Jira Server, I never used it, our deployment type is Cloud, so maybe you need to create a new question.
OK thanks, will do.
My questions posted here for future reference: https://community.atlassian.com/t5/Jira-Software-questions/Rule-Triggered-By-User-Mention-in-Comment/qaq-p/1404679#M82615
I was also having an issue using the format:
Instead I was able to do this:
Hello All ,
Thank you for providing the solution on how to pick a mentioned user in a comment . Do you know how to pick multiple mentioned users in a comment and paste all of them in a multi-picker user field in a ticket ?
Thanks for your help .
Best ,
Mohamed
Hello everyone,
I have the same issues as Mohamed.
Using the below smart value works but only if one person is tagged in the comment and it does not update my user-pick field, instead it replaces the whole value with the new one.
What I need is very much the above but that would get all IDs from the e.g. 3 people tagged in the last comment of an issue and add those people additional to the already existent value of the field.
I also tried the below smart value from another similar thread and that unfortunaty does not return any value when people are tagged.
{{issue.comments.last.body.split(" ").match("(accountId:.*)]").remove("accountId:")}}
Would that be possible, if yes how can I do it?
Thank you!
Okay, the Jira support team helped me find the solution I was looking for.
You can see the detailed information here.
It looks like you're new here. Sign in or register to get started.