Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira Automation to send a Microsoft Teams message to anyone that is @mentioned in a comment?

Cliff Stovich December 20, 2023

I'm attempting to send a Teams notification to anyone who is @mentioned in the comments of any issue. So far I have a rule that captures the user id of any user that is @mentioned in a comment. I took it from @Bill_Shaboy from an old thread (https://community.atlassian.com/t5/Jira-Content-Archive-questions/Need-to-add-all-the-users-mentioned-in-the-comment-to-the-custom/qaq-p/2061760)

The code is 

{{issue.comment.last.body.split("\n").match("\[~accountid:(.*)\].*")}}

Once all of my mentioned users are in there I would like to print the user names in a Microsoft teams message. Right now the message is printing user ids which are gibberish. So far the rule looks like the attached picture. Any help on next steps would be appreciated. Screenshot 2023-12-20 141504.png

 

1 answer

1 accepted

2 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.
December 20, 2023

Hi @Cliff Stovich 

After the GDPR changes for privacy, the account id values are all that is available from the mention.

If there was just one user, you could call the REST API functions to get their name.  But with multiple users that might not work because of limitations with list iterators.

An elaborate work-around for the multiple user scenario could use a custom field:

  • add a multiselect, user custom field to your project
  • in the rule...
    • use the extracted account id values from the mentions to create a JSON expression
    • use that JSON expression to set the custom field values
    • re-fetch issue, to load the data again
    • now the custom field values can be iterated to return their displayName attribute to send the Teams message
    • when done, consider clearing that custom field again for clean-up

Kind regards,
Bill

Cliff Stovich December 21, 2023

Thanks for the info that doesn't seem too difficult to implement. One quick question. 

Is my current MentionedUser variable storing those user ids as one long string or as different values of some other data type in an array?

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.
December 21, 2023

Based on the image shown, I expect that match() results in comma-separated values of the account ids as text.  (I always write stuff like that to the audit log after the action to confirm it contains what I expected.)

To use that as a list, split your variable with split(",") and iterate over it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events