Look for same Issue Summary
Asked by Ellen O_Leary:

Our JIRA Core instance creates issues via email. We would like to ensure that emails with the same Summary line (with the same sender) update existing issues rather than create new issues.

For example:

1. First email comes into JIRA with the subject line: Testing1, and is from ServiceAccount1, that should create a new issue.
2. Then, if a second email comes in with a subject line of: Testing1, and is also from ServiceAccount1,
3. We want the body of the second email to update as a comment to the first issue rather than creating a whole new issue.

Can anyone offer insight here?


Answers:
author: JD
body: Hi [@Ellen O_Leary](/t5/user/viewprofilepage/user-id/1149740)

Jira has existing functionality that will put emails as comments when the email subject contains an issue key.

Can I ask more about the use case you're trying to solve? Is this for a service desk where customers email issues through?

I may have a hacky way to help using automation but it might not work 100% of the time.

Thanks,

John

comments: author: Ellen O_Leary
body: Thank you, [@JD](/t5/user/viewprofilepage/user-id/1240728).

Yes, we utilize the reply function to create additional comments on the same issue.

However, in this case, we are sending 2 distinct emails (from the same sender) to the catch-mailbox for JIRA Core. The JIRA system is reading the second email as different and creating a second issue, rather than recognizing it as a reply (b/c it is technically not) and applying comments on the primary issue.

Unfortunately, the system that generates the emails does not read back from JIRA to get the Issue Key number. However, both emails do contain a unique Work Order number generated by our system that spawns the emails.

I was hoping to use the Automation feature to assist with this, but haven't figured out how to do that yet either.

I'm interested in any advice!

Thanks so much!

Ellen


author: JD
body: Ok so this is a bit hacky and I have not tested all cases (but I think it works). I'll explain each component and configurations below the image.

The automation is run whenever a new issue is created. It checks to see if any existing issues have the same issue summary and reporter. If it finds one it will add the new issues description as a comment to the existing issue and then transition the duplicate issue (the new issue) to done.

You will need to do some improvements to the JQL to reduce the impact on your Jira instance, I'll run through it below.

![Automation-duplicate-issue.png](https://community.atlassian.com/t5/image/serverpage/image-id/116599i3A9AD736FB109F1B/image-dimensions/768x772?v=v2 "Automation-duplicate-issue.png")

**Components**

1. Issue created: triggers the automation whenever an issue is created.
2. Create variable: I named the variable **duplicateExists** and set its value to **null**. You create the variable at the start so it can be used in and outside of the branch component.
3. Branch: With a relationship type of **JQL** and then I used some [smart values](https://support.atlassian.com/jira-software-cloud/docs/what-are-smart-values/) in the JQL search.

   ```
   reporter in ({{issue.reporter}}) AND summary ~ "{{issue.summary}}" AND created != "{{issue.created.jqlDateTime}}"
   ```

   <br />

   Automation will replace the information in the curly brackets with the values of the trigger issue (e.g automation will change {{issue.reporter}} to *ServiceAccount1* ).  

   I'd suggest making your JQL more specific than I have, this will reduce the number of results the automation rule has to process. I would add something around the type of issue that is created and the status of the issue (unless you want it to apply to done issues). Also any other criteria you can think of to reduce the search will help.

   ```
   AND issuetype = <input the type of issue your emails make> AND status in ("To do", "In Progress") 
   ```

4. Issue field condition (inside the branch we created): Check if the summary equals the summary from the trigger issue. This is because JQL does a fuzzy search when matching words so it will include results that have the same words but they might be in a different order. So we'll remove those results now  
   ![Screen Shot 2020-10-30 at 10.43.29 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/116600i41A9F68704DE4FA4/image-dimensions/370x226?v=v2 "Screen Shot 2020-10-30 at 10.43.29 am.png")
5. Comment on issue (inside the branch we created): This will add a comment to any issue that is found in the above JQL search, so if there are multiple issues with the same reporter and summary then they will all have the comment added.  

   For the comment I'd suggest {{triggerIssue.description}} this will comment whatever is written in the description of the issue that triggered the automation rule. Also if you want to link to the duplicate issue you could use {{triggerIssue.key}}.   

   ![Screen Shot 2020-10-30 at 10.48.12 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/116601i76E5A7943CF01F22/image-dimensions/406x275?v=v2 "Screen Shot 2020-10-30 at 10.48.12 am.png")
6. Create variable (inside the branch we created): Now we want to set the variable we created earlier to "true", this is to show we found a duplicate issue in our JQL search. If no issues are found in our JQL then this will still be "null".   
   ![Screen Shot 2020-10-30 at 10.51.31 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/116602i52EA2FAA89A34148/image-dimensions/371x248?v=v2 "Screen Shot 2020-10-30 at 10.51.31 am.png")
7. Advanced compare condition (**Outside** the brach): This will check the variable we created and if it is true it will run continue the automation.  
   ![Screen Shot 2020-11-02 at 9.10.39 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/116603i5413427DE44A1257/image-dimensions/450x227?v=v2 "Screen Shot 2020-11-02 at 9.10.39 am.png")
8. Transition issue: this will transition the duplicate issue to done.   

Let me know how you get a long. The main issues I ran into was my JQL being slightly wrong. So you might want to do a JQL search in the issue navigator first and then replace parts with smart values.


author: Ellen O_Leary
body: Thank you, [@JD](/t5/user/viewprofilepage/user-id/1240728)

I really appreciate you taking the time to experiment for me!

Unfortunately, I am experiencing 2 separate hurdles with this solution:

1. I do not seem to have the ability to Create Variable within an automation.
2. The Compare Condition does not allow me to select Summary in the second dropdown.

I am not sure if or how to enable these features within the add-on. We have version 7.2.2 of the automation add-on to our Jira Core 8.7.0 instance. Am I missing something that needs to be turned on?


author: Volker Kiehn
body: Hi [@JD](/t5/user/viewprofilepage/user-id/1240728)

I was very interested in your example. I had an issue with special characters in summary but I got help from the support.

Using this query will fix it  

summary \~ "\\" {{ issue.summary }} \\""

I'm now using following JQL for the branch and it's working fine

reporter in ({{issue.reporter}}) AND summary \~ "\\"{{issue.summary}}\\"" AND created != "{{issue.created.jqlDateTime}}" AND status != Ready   

(for all germans: status != Fertig )

thanks a lot

Volker