Big ask: Auto link tickets when it contains the same number

Mimi Peters May 11, 2023

Hi there,

We put some numbers in Summary as a reference and these numbers are 7-9 digit numeric only. Is there a way when it matches then the ticket will auto link to each other? 

If 3 tickets have a summary like the below then with the automation rule, all will be linked with reason "Reference to"

  1. ABC XYZ 123456789
  2. 123456789 BCD EFG
  3. LMN 123456789 OPQ

Many thanks,

MM

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

Hello @Mimi Peters 

Yes, this is possible.

You can use the match function against the Summary text field to pull out the number portion of the string.

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--

If you use that to set the value on a variable you create, then you can use that variable in a For Branch / Related Issues / JQL where the JQL is one that will find all issues where the Summary field contains the value of the variable.

Then use the Link Issue action to link each of those to the trigger issue.

Mimi Peters May 12, 2023

Hiya @Trudy Claspill many thanks for your suggestions. So glad it can be done.

After experimenting, I did a test with both issues has a summary "test 12345678 test" but both issues have no not linked together. Did I miss something in my rule?

1.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

The IF step is a Condition. A Condition checks to see if the current issue meets a condition. In this case you are checking that the issue that triggered the rule has a 7-9 digit string in its Summary. This type of step does not look for other issues that have the same value.

Here is the basic structure you need:

Trigger: 
Condition: Field Value :
check if the Summary field contains a numeric string
Action: Create Variable :
use the .match function to pull the numeric string from the Summary and assign it to a variable
For Branch / Related Issues / JQL
create a JQL that searches for other issues with the same numeric string; i.e.
summary ~ {{variableName}}
Action: Link Issues
Mimi Peters May 16, 2023

I did not manage with the above, when you have a moment. Is it possible to post a screenshot in your convenient time please?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2023

I used 10 as the number of digits I wanted to match.

 

Screen Shot 2023-05-17 at 1.24.36 PM.png

Mimi Peters May 17, 2023

Thanks Trudy, just tested the rule seems success but it said no related issues could be found. However 2 of the ticket got 10 digits the same so they should be linked automatically but it doesn't. Could you have a look and see what did I missed please?

image (4).pngimage (3).png1.png

Mimi Peters May 17, 2023

1.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2023

Your Create Variable step is wrong. You need to set that variable to the 10 digits that are in the Summary of the trigger issue.

{{issue.summary.match(".*(\d{10}).*")}}

Screen Shot 2023-05-17 at 4.53.05 PM.png

Mimi Peters May 17, 2023

Cool, Trudy. It works beautifully. :) :) 

1. In this automation, can I add also if someone removes or changes the digits it will unlink the Jira since they are no longer matches? 

This is mainly in case someone realized its a mistake on one of the digits, and corrected it. Then we don't need to manually unlink the Jira and the automation takes care of it. 

2. Now knowing that works, should I copy this automation rule and create one for 7 digits, one for 8 digits etc.? This is due to some account numbers being 7 digits and some account no. are 8 digits.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2023

1. That is a scenario I would have to spend additional time researching, and I don't have the time to do that now. It is not a straight forward situation because the digits are part of a larger string. Detecting that it is the digits that changed vs. another part of the Summary would be the first challenge. The next challenge would be identifying the linked issues that were linked because they originally had matching digits vs. issue linked for other reasons.

2. I have not spent a lot of time working with regex expressions, so there may be a more elegant solution to this than what is within my experience.

If you might have digits of varying link in the Summary, and if it is possible for a shorter value to be part of a longer value, then I would probably use two rules, and I would change the regex expression to include looking for a character that indicates the end of the digits has been reached, if that is possible. Will the digits always be followed by a space, or a period?

 

I personally would probably look a different solution that makes it easier to clearly identify the digits, such as using a custom Number field for the digits rather than putting them into the Summary field. As long as your numbers don't have 0's at the beginning a Number field would work. If they might have 0's at the beginning then you would need a Text field, and you could end up with non-numeric values in it unless you add validation of the value that is entered.

Like Mimi Peters likes this
Mimi Peters May 17, 2023

Indeed that make more sense using a number field, we want to allow the user can simply type the request in List view in New Gen Jira so its much faster :) thats why.

 Upon testing, we also discover that if the summary has 2 strings of numeric like below it won't link also. Any solution would fix this? My back up plan is we have to leave with some odd cases that wont linked

1234567899 - WD - 167688400100

1234567899 - ABC - 985424494100

Mimi Peters May 19, 2023

Hi Trudy,

With the help from my colleague, we found this will work. Wanted to share it back to you with this site. We use this one to test the regex https://regex101.com/

(\d{8}$)|(^\d{8})\s|\s(\d{8})\s

What's left, still to be fixed as I am trying to figure out also include the below cases. In an ideal scenario, if the Summary contains happens, the first item will link to 2 and 3 respectively. 

  1. 1234567 TEXT multiple accounts no. 7654321
  2. 1234567 TEXT 
  3. 7654321 TEXT

Regards

MM

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 19, 2023

The documentation for the match function says it will return multiple matches as a set. I haven't gotten that working yet. Created variables are always strings, though, and I'm not sure what happens if you try to assign a set to a string. It might end up as literally [<your first number>,<your second number>] 

Then you'd have to figure out how to parse that (maybe with the "split" function?) and iterate over the values.

I won't have time to work more on this soon, but I'll add it to my list to continue investigating. If I figure out anything I'll post back here.

Like Mimi Peters likes this
Mimi Peters May 21, 2023

Same here :) will share if I find out from my end.

Like Trudy Claspill likes this

Suggest an answer

Log in or Sign up to answer