Forums

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

Smartvalue problem for Regex with commas in automation

Brandon Hennegan x368 October 24, 2024

I have been using this regex to find reference to other ticket in comments and make a related link:

[A-Z]+-\d+

it works, but it is too general and often causes errors for things that aren't really a ticket descriptor. I changed to this:

[A-Z]{2,8}\b-\d{3,6}\b

which is specific enough to catch things much more finitely. 

 However, when the automation runs the command to establish the link

{{comment.body.match("{{[A-Z]{2,8}\b-\d{3,6}\b}}")}}

it fails because it is seeing the commas in the regex as delimiters and generates this error:

{{comment.body.match("{{[A-Z]{2: Issue does not exist or you do not have permission to see it., 8}\b-\d{3: Issue does not exist or you do not have permission to see it., 6}\b}}")}}: Issue does not exist or you do not have permission to see it.

Any ideas on how to fix this?  

2 answers

0 votes
Jim Knepley - ReleaseTEAM
Atlassian Partner
October 24, 2024

Hi @Brandon Hennegan x368 

Do you mean to match the literal {{   }} sequences in your input string? If so, you might need to escape them.

{{ comment.body.match("\\{\\{[A-Z]{2,8}\b-\d{3,6}\b\\}\\}") }}

 

Brandon Hennegan x368 October 30, 2024

No not trying to match {{ sequence.

0 votes
Robert DaSilva
Community Champion
October 24, 2024

Hi @Brandon Hennegan x368 ,

Could you post a screenshot of your automation rule here? I suspect you're trying to attach the link, and search the comments in the same step.

If that's the case, I may suggest creating a Variable a few steps ahead in the rule, and then referencing that variable (if it returns something) in the Link step instead.

Brandon Hennegan x368 October 30, 2024

 

 

2024-10-30_16-03-50.pngand here's the original that works (but is too general, but doesn't need comma's)

2024-10-30_16-05-50.png

Brandon Hennegan x368 October 30, 2024

I tried the variable option and it seemed promising as it didn't cause a comma error, but it also doesn't seem to catch any return from the regex (even though the exact same regex is resolving as true in the IF comparison check.   A log of the variable returns blank.  

Suggest an answer

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

Atlassian Community Events