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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
that works fine, perfekt.
Now I want, for example, send an E-Mail to that user. Has somebody an Idea how to proceed with the extracted accountId?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Eva Pfister,
I believe you should make a get request to the Jira API to get an email address for future reference. Here you can find how to do that. And here is the API endpoint you need.
You can access the email address from the API response with dot notation using the following smart value:
{{webhookResponse.body.emailAddress}}
Here you can find more about {{webhookResponse}} smart value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was also having an issue using the format:
\[~accountid:.+\]
Instead I was able to do this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~accountid:").remove("]")}}
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, the Jira support team helped me find the solution I was looking for.
You can see the detailed information here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.