Hi, I need to add all the users mentioned in created comment to custom field Cooperators.
Cooperators is a field with type "User Picker (multiple users)".
How to do it in Jira automation?
Thanks in advance for any suggestions.
A couple of ways to do this are with an advanced, smart value branch to loop and with a single edit:
Please consider if you want to clear or add to existing Cooperator values if multiple comments occur.
This is a complicated rule to write, so I recommend doing it one step at a time and writing the intermediate results to the audit log before making any edits to the issue.
Kind regards,
Bill
Bill, thank you for answer.
Don't you have an example for "regular expression with match() to parse the users' account ID values out of the comment" ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Martin.
Writing automation rules often requires experimentation. I encourage you to try things, such as writing comments to the audit log, to learn more about how Jira implements things like mentions...as that will give you ideas for how to parse them with regular expressions.
To get you started, this expression will return a list of user account ID values for the last comment added:
{{issue.comment.last.body.split("\n").match("\[~accountid:(.*)\].*")}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
already over a year old but I found your proposal and started using it but then I realized that the RegEx isn't fully correct and I am struggeling to get there - maybe you can/want to have a look?
The issue is that if there are multiple accountIds with text inbetween like "," or "and" they end up in the result as well as the regex doesn't stop for each accountId.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First, for an older thread like this, I recommend creating a new question and linking back to the older one. That will ensure the most number of people see it to help. Otherwise only the people following the old threads see them. Thanks!
Without seeing the details of your rule and a sample of your text with mentions...I suspect this is more of the challenges in the regular expression implementation for automation rules. The documentation describes they are "based on Java's Pattern class and uses Matcher.find() to find matches". However they do not describe what does / does not work the same.
In my earlier post, I suggested splitting on newlines to help the match() reduce the scope of match attempts. That might help for your case. I just retested with mentions separated by commas and "and" and the matches found all of them.
Kind regards,
Bill
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.