Find issue with JQL and issue key as smart value
Asked by dstivanov:

Hi there!

I am trying to setup an automation, which parses github PR webhook payload, finds an issue based on this payload and comments under the issue that a PR is opened.

Unfortunately I am facing a problem with the JQL, because in order to get the issue key I need to extract if from the webhook payload.

Here is my JQL condition:

```
key = {{webhookData.pull_request.title.match(".*(RM-\d{4}).*")}}
```

* I am absolutely sure that the smart value is working, because I am audit logging the same value in the previous step and it returns valid issue key;
* I have tried the super simple JQL in Jira and the issue is found;

However, when the automation rule is executed, My JQL condition reports

"***No issues were found, stopping the rule.***"

I found a super old bug about similar problem in [AUT-516](https://codebarrel.atlassian.net/browse/AUT-516 "Smart values inside JQL statements should be enclosed with \"") and have tried the folowing options (none of them worked for me):

* enclosing the smart value in single quotes ( ' ... ');
* enclosing the smart value in two single quotes ( '' ... '');
* enclosing the smart value in single quotes and escaping the double quotes in the regex;
* enclosing the smart value in double quotes ( " ... ");
* enclosing the smart value in double quotes and escaping the double quotes in the regex.

Here are some screenshots: ![Screenshot 2020-05-29 at 14.53.33.png](/t5/image/serverpage/image-id/96996i3AE6009B67457AA8/image-dimensions/208x350?v=v2 "Screenshot 2020-05-29 at 14.53.33.png")\& ![Screenshot 2020-05-29 at 14.53.49.png](/t5/image/serverpage/image-id/96997iD5B2C891CA451803/image-dimensions/334x139?v=v2 "Screenshot 2020-05-29 at 14.53.49.png")

I am sure that I overlook something and will need you help, community!

Best from me,

Dimitar


Answers:
author: dstivanov
body: The answer to this it pretty straightforward. We have to use Incoming Webhook as a trigger with "Issues provided by running the following JQL search". Here is a screenshot of the working rule:![Screenshot 2020-06-23 at 11.16.11.png](https://community.atlassian.com/t5/image/serverpage/image-id/100029iD666F6D503FB5A00/image-size/large?v=v2&px=999 "Screenshot 2020-06-23 at 11.16.11.png")

comments: author: Karin Berg
body: I do the same as suggested here but when the title does not contain an expected issue string like "RM-123", then the automation fails and send me an email.

Is there a way to set a default value if no issue string is found? Or another way to avoid an error for this situation?


author: Karin Berg
body: Ok, I figured it out by myself.

I use the option "No issues from the webhook" in the "incoming webhook". Then I add the following steps to the automation:

1. "Create variable": This stores the extracted issue key from the pull request title into the smart value variable "issue".  
![Screenshot 2022-04-06 at 17.13.17.png](https://community.atlassian.com/t5/image/serverpage/image-id/191782iBC2183F375F41B87/image-size/large?v=v2&px=999 "Screenshot 2022-04-06 at 17.13.17.png")

2. "Advanced compare condition": This has the effect that if there was no issue key in the title of the pull request, I do not execute the next steps in this automation.  
![Screenshot 2022-04-06 at 17.13.35.png](https://community.atlassian.com/t5/image/serverpage/image-id/191784i067C3DEF42AD4473/image-size/large?v=v2&px=999 "Screenshot 2022-04-06 at 17.13.35.png")


author: Martin Cleaver
body: You are lucky - you are running on Cloud.

Atlassian appears to be holding off from implementing "Create Variable" in DC.


Tags: jql

smart-value