Help with automatically linking two jira tickets with matching labels
Asked by Mat Levell:

Hey all, Ive been looking on the forums but haven't been able to get exactly what I need.  
Im trying to link two issues (different project) of the contain the same label value. Im using Jira Automation and I was able to get my logic to run but its not finding the matched issue and in turn not linking.![Screenshot 2024-09-23 at 2.00.30?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348832iBA62EDC7F4F661CD/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 2.00.30?PM.png")![Screenshot 2024-09-23 at 2.06.50?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348833i97066E5BE4E95685/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 2.06.50?PM.png")


Answers:
author: said kouzibry
body: Hi,

* What does the smart value *{{triggerIssue.customfield_10301}}* return ?
  * Use a "Log action" with that smart value and see what it returns, then try a normal JQL search using the value returned, this might give you a better idea of what is happening.Something tells me the field "original vehicle id" is a text field, in which case you should use the operator **\~** instead of **=**
* The "For : Current issue" component looks off to me, I would use "For : JQL" instead

Here is an example of what I have in mind based on what I unserstood from your description

![chrome_Bhl1LDb9jT.png](https://community.atlassian.com/t5/image/serverpage/image-id/348839iA4DBA81A2CBE4280/image-size/large?v=v2&px=999 "chrome_Bhl1LDb9jT.png")

I hope this helps, let me know what you find out.


author: Bill Sheboy
body: Hi [@Mat Levell](/t5/user/viewprofilepage/user-id/5568611)

First, I notice what appears to be a typo in the JQL for your Lookup Issues action: there is a space between the period and the custom field id.

Next, you note the issues are in different projects. What is the scope of your rule: single-project, multiple-project, or global?

A single-project scope rule can create (or clone) issues in other projects, but it cannot access them otherwise. For the lookup to access issues in another project, and then link them, the rule must be multiple-project or global in scope.

Your Jira Site Admin will need to change the rule scope as it is changed in the global rule configuration area of Jira.

Kind regards,  
Bill

comments: author: Mat Levell
body: Thanks [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) the typo fixed the finding problem but now its not linking to each other. I suspect im doing something wrong with the branch and link.  
![Screenshot 2024-09-23 at 2.45.09?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348841iF36A9FEAA29C0540/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 2.45.09?PM.png")  
![Screenshot 2024-09-23 at 2.47.58?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348842iE59FA4FA19C2E0F0/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 2.47.58?PM.png")


author: Bill Sheboy
body: If you want to link those issues to the trigger issue, use a branch on JQL rather than the Lookup Issues action.


author: Mat Levell
body: Thanks [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I got it working but if I use more than 1 label on the source issue it doesn't work. I source issue might have many labels that will link to a many issues in the other project.![Screenshot 2024-09-23 at 3.12.25?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348848i6D02995214644FD1/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 3.12.25?PM.png")![Screenshot 2024-09-23 at 3.09.59?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348849i46B577FEF2576680/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 3.09.59?PM.png")![Screenshot 2024-09-23 at 3.09.35?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348850i1600B771A3FC30A9/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 3.09.35?PM.png")


author: said kouzibry
body: Change the JQL to **"original vehicle id" in ({{triggerIssue.customfield_10301}})**with no quotes around the smart value.


author: Mat Levell
body: Hi [@said kouzibry](/t5/user/viewprofilepage/user-id/1613821) I tried changing it to "In" and removing the quotes but since im using a label field I dont think its supported. (last resort I can change it to list field)  
![Screenshot 2024-09-23 at 5.50.02?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348859iA478F02ACD9F8800/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 at 5.50.02?PM.png")


author: said kouzibry
body: You need parenthesis around the smart value so that when it's interpreted, it would give something like **"original vehicle id" in (FME100005)**


author: Bill Sheboy
body: You are missing the outer parentheses that [@said kouzibry](/t5/user/viewprofilepage/user-id/1613821) suggested.

What is the type of this custom field? That may impact the syntax used for the JQL.

Next, when there are multiple values in the trigger issue, are you trying to match on **any values** provided, on **all values**, or both possible cases?


author: Mat Levell
body: yep the parentheses were the problem, It was two custom field (label). If the label/s matched from the CIT issue, it would automatically link to 1 or many VCB issues (there is one matching value in the VCB project). You've both been extremely helpful, I would have been lost without you!!!![Screenshot 2024-09-24 at 8.34.40?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/349043i0F2C58ADD915C7B7/image-size/large?v=v2&px=999 "Screenshot 2024-09-24 at 8.34.40?AM.png")


Tags: automation

cloud

jira-cloud