Automation Lookup issues fails to find
Asked by Aron Kuch:

I am building an automation to link issues with the same external ID to across projects in Jira. I tried using the Lookup issues action. I started with

![Jira Automation Lookup Issue.png](https://community.atlassian.com/t5/image/serverpage/image-id/316326i47101CC0458D0ED8/image-size/large?v=v2&px=999 "Jira Automation Lookup Issue.png")

But it fails to find anything. From the Audit Log:

![Jira Automation Lookup Fail.png](https://community.atlassian.com/t5/image/serverpage/image-id/316317i8F40A8706F91E7CD/image-size/large?v=v2&px=999 "Jira Automation Lookup Fail.png")

I replaced the {{issue.REDCap ID}} with an actual value, 1102, and still received that "result". The JQL with a set value works when used in Issue Search and it returns one record like it should.

![Jira Issue Search.png](https://community.atlassian.com/t5/image/serverpage/image-id/316328i67EEC871BCD55621/image-size/large?v=v2&px=999 "Jira Issue Search.png")

Do I need to use the custom field id number in the automation JQL? Any other ideas why it isn't returning results?


Answers:
author: Kalyan Sattaluri
body: Hello [@Aron Kuch](/t5/user/viewprofilepage/user-id/5326795) As [@Mark Segall](/t5/user/viewprofilepage/user-id/4666637) has suggested do try surrounding it in quotes... But one other thing, You mention you are searching across projects, please also make sure your rule scope has "MAIN" project included. If you dont have scope, you wont have hits.

comments: author: Aron Kuch
body: Ah, rule scope. I had set it to one project because I just wanted the one project to link back to the first. But appears to have limited the JQL search to just that project.  
I changed to Global scope, multiple projects could also have worked, and it ran. Thank you.  
I assumed that issues in MAIN would now trigger it when there REDCap ID field was populated, so I created an condition component to filter to just issues on the project that I want the run to trigger on. When I tested with a MAIN issue, the rule started, but terminated when the " issues did not match the condition".  
Thank you again, this solves this part of the automation.


author: Bill Sheboy
body: Hi [@Aron Kuch](/t5/user/viewprofilepage/user-id/5326795)

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!

Until we see those...

**Smart values are name, spacing and case-sensitive.** And, often the smart value does not match the displayed field name on the views. When the incorrect smart value is used, it often fails silently, as you see with no issues found for the lookup issues action.

To confirm that JQL is using the correct smart value for your field, please use this how-to article. Essentially, you use an example issue with your field, call a REST API function with a browser, and search for your field on the page to find the correct smart value (or custom field id).

<https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>

Kind regards,  
Bill


author: Mark Segall
body: Hi [@Aron Kuch](/t5/user/viewprofilepage/user-id/5326795) - I believe what you have will work, but you need quotes. Try this:

```
project = MAIN AND "REDCap ID" ~ "{{issue.REDCap ID}}"
```

comments: author: Aron Kuch
body: Reasonable, but I tried that and didn't resolve.


author: Mauricio Heberle
body: This lookup wont work, you are telling jira "look for a project = main and a field called "REDCap ID with a literal text value {{issue.REDCap ID}}. Thats why your second print works.

Heres some documentation:  
<https://support.atlassian.com/jira-software-cloud/docs/jql-operators/#CONTAINS---->  
<https://support.atlassian.com/jira-software-cloud/docs/search-for-issues-using-the-text-field/>  
<https://confluence.atlassian.com/automation074/text-functions-1141481322.html>

Using vanilla JQL, i dont think its possible to compare strings. Firtst idea that comes to mind is that you will need to create a variable (create var component) and compare it using a string function.  

Create var = REDCapId  

{{issue.REDCap ID.match("REDCapId")}}  

That would take some testing.


Tags: jql