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

Transition and Assign issue to @mention from comment

Brendan Betheldo May 12, 2024

Hello!

I am trying to create an automation, I have had so much trouble with this task though.

Want:

When 'peer review' is mentioned transition to the workflow step In Peer Review AND Assign the issue to the user @mentioned.

What I have tried:

Jira Transition and assign automation.PNG

Any help on what I've missed would be appreciated.

Cheers,

Brendan

1 answer

1 accepted

0 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.
May 13, 2024

Hi @Brendan Betheldo 

What does not work as you expected, and what does the audit log show when you try your rule?

What does your Assign Issue action contain?

 

One way to do this is to select the Smart Value option with the Assign Issue action, and use this smart value expression:

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

If multiple people are mentioned, this will not work because only one user can be assigned.  To prevent that case, you could add a smart value condition earlier in the rule which only proceeds when one-and-only-one person is mentioned.

Kind regards,
Bill

Brendan Betheldo May 13, 2024

Hi Bill, apologies for the lack of context. The issue I had was being unable to find the user mentioned. 

I was on the right track with accountid thanks to the docs but didn't think to use regex in a smart condition. 

Your solution accomplished my task perfectly. 

What's the level of string manipulation we can do in these smart value conditions?
I think it'll be acceptable to run the rule and always get the first mentioned ID.

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.
May 14, 2024

Regarding the level of string manipulation, that depends on context.  Outside of list iterators, the built-in functions offer quite a few options: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/  Inside of an iterator, some things appear not to work, which I hypothesize is due to scoping problems.

 

For the expression I provided, it would return zero-to-many results for all mentions found.  If you wanted to add handling for only the first entry...

This would return the count of mentions found:

{{issue.comment.last.body.split(" ").match("\[~accountid:(.*)\]").distinct.size|0}}

And this would return the first one, and nothing if no user was mentioned:

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

When no user is mentioned, this expression used with Assign Issue would set the issue to unassigned.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events