Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

If an automation was triggered by a new comment, how can I check if there was a linked ticket

James_Gigantes
Contributor
October 28, 2022

I have an automation which runs when there is a new comment.

I would like to check if there is a linked ticket prior to running there rest of the automation. I have tried to utilize regex via smart values. {{comment.body.match("(MAR-/d+)")}}. This works to create a linked issue later in the automation. Though I either cant get the format to run properly, or im not appropriately addressing it as Boolean 

What I have tried:
Comment link true.JPGComment link true 2.JPG

 

3 answers

2 accepted

3 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.
October 28, 2022

Hi @James_Gigantes 

Do you mean you are looking for mentions / references to other issues in the comment, or to linked issues?  If linked, please see Jack's answer.

If you want mentions / references...

The match() function returns matching values, not true or false: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--

To do what you ask check if the result is not empty instead of "true".

Kind regards,
Bill

Jack Brickey
Community Champion
October 28, 2022

good point Bill

James_Gigantes
Contributor
October 28, 2022

I am looking to see if there are any mentions/reference to a ticket (CTRL+k then type a ticket number in the comment text box) in the trigger comment. Then setting that as a linked ticket. I am doing this as it is reporting errors every time when someone posts a comment without an issue key in the comment.

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.
October 28, 2022

Thanks for clarifying, James.

You may then want to consider using match() to extract the zero-to-many matches, using them to feed the linking...either in a single JSON update or using an advanced branch to walk them.

Like # people like this
James_Gigantes
Contributor
November 1, 2022

@Bill Sheboy  Thank you!

0 votes
Answer accepted
James_Gigantes
Contributor
November 1, 2022
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.
November 1, 2022

Yes, and I believe that example rule from the library works for one mention, not multiple.  Have you tried it with multiple mentions?

James_Gigantes
Contributor
November 1, 2022

Yes and it works! Woop woop!

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.
November 1, 2022

I am glad to hear that, and a bit puzzled...

It seems there is even more variability than I suspected in the automation rule actions as Link Issue appears able to take a single value or a collection...which is undocumented behavior.

Jack Brickey
Community Champion
November 2, 2022

Guys, that link didn't take me to a specific rule in the library . Can you elaborate on the actual rule? 

James_Gigantes
Contributor
November 2, 2022

Did you try scrolling 3/4 of the way down the page? I think someone on the UX team should make a required update that the library results take you to the top of the page, or links change as a user scrolls on page to different anchors. Either way... Here is a screenshot of the rule. I think what was happening is I wasnt addressing the results of the match properly. I haven't worked with regex in a minute, and it was difficult to find documentation with a few examples. automation quesiton answer.JPG

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.
November 2, 2022

Hi, @Jack Brickey 

FYI that I sometimes find the automation rule library "glitches" and is unavailable for a period of time, leading to an empty page with just library heading.  It often reappears a few hours later.  This seems to happen regardless of the browser used.

Kind regards,
Bill

Like James_Gigantes likes this
0 votes
Jack Brickey
Community Champion
October 28, 2022

hi @James_Gigantes , if you're simply wanting to check if a link exist before proceeding further into the automation rule you can use the advance compare condition. Here is an example...

2022-10-28_11-41-52.jpg

So that you don't have to retype here is the Smart value text...

{{#issue.fields.issuelinks}}{{id}}{{/issue.fields.issuelinks}}

James_Gigantes
Contributor
October 28, 2022

Please see my reply to Bill above. I am looking to see if there are any mentions/reference (CTRL+k then type a ticket number in the comment text box) in the trigger comment. Then setting that as a linked ticket.

Jack Brickey
Community Champion
November 1, 2022

yes i saw that. i see you accepted Bill's answer so assume his recommendations worked for you?

James_Gigantes
Contributor
November 1, 2022

Testing it now. It seems straight forward. 

@Bill Sheboy @Jack Brickey automation quesiton.JPG

Like Jack Brickey likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events