How to avoid duplicate issues being created by an external service

Drew Nedderman June 19, 2019

We have Jira Service Desk Cloud. We also have an external service that reports on issues every 15 minutes until the particular issue is solved. For example, we are an ordering platform for restaurants and sometimes a product order will fail to be sent onto their foodservice vendor. We have an alert from the external service that says order number xxxx failed. If the order hasn't gone through by the next time the service checks for it, we get another alert. 

The alerts come via a particular email address. The body and subject of the email is the same every time it fires.

I see one ticket per instance of an order number that is failing, so if order number xxxx is failing, I would see one ticket for the first time the service checked, then another ticket for the next time the service checked and so on.

I would like to avoid these duplicates. Since the body and subject of the emails are identical to one another, is this possible through an automation of some sort? I have ScriptRunner and Automation for Jira, but haven't been able to solve this yet.

It doesn't look like advanced mail loop detection is the right fit here since the emails are 15 minutes apart.

Thank you!

 - Drew Nedderman

3 answers

1 accepted

2 votes
Answer accepted
Simon Wong March 10, 2021

@Drew Nedderman @If Else

You can try using the Lookup Issues action under Automation https://support.atlassian.com/jira-software-cloud/docs/automation-actions/#Automationactions-Lookupissues. You can run a JQL to identify if there are already existing records with the same Summary field as the new issue. If so, cancel (or deleted if you'd like) the new issue automatically. 

See the example below.

Project_automation_-_JIRA.png

Lilian December 2, 2021

Thanks for this, it was very helpful. I can confirm it works, but needs  a few changes, mainly removing the special characters from the searched summary and escaping quotes (

+ - & | ! ( ) { } [ ] ^ ~ * ? \ :

as documented here: https://confluence.atlassian.com/jiracoreserver073/search-syntax-for-text-fields-861257223.html#Searchsyntaxfortextfields-escapingSpecialcharacters).

 

summary ~ "{{issue.summary.replace("\"","\\\\\\\"").remove("*").remove("{").remove("}").remove("[").remove("]").remove("+").remove("-").remove("&").remove("|").remove("!").remove("(").remove(")").remove("^").remove("~").remove("?").remove("\\\\").remove(":")}}"


Another change I made to simply delete the newly created ticket instead of transitioning to Canceled. 

Like Simon Wong likes this
0 votes
WAJDI ALZINATI March 20, 2022

Hi , 

How can I do the same for a custom field, We need to avoid duplicated issue with same data.

Thanks for help, We have Jira Server

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 19, 2019

Speaking about server here... but I think the same is true for cloud.

The default mail handlers have mail threading handling capability.

But that is based on the "message-id" header. If you can somehow cause the external service to generate and re-use a single message-id header for a given alert, then each new email will be appended as a comment on the initial issue created.

Scriptrunner doesn't come between your mail handler and the ticket creation.

The only thing that scriptrunner can do for you is react to the ticket creation, check if a similar ticket exist, then delete or discard the newest one.  But any notification associated with the ticket creation or deletion will still take place.

Drew Nedderman June 21, 2019

I'll reply back here once I've had a chance to test this. Looks like it could work.

Drew Nedderman June 21, 2019

Hi Peter-Dave, we tried sending emails that had duplicate message-id headers, but no luck. Each email created a ticket. Any other thoughts on this? Thank you!

 

 - Drew Nedderman

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 21, 2019

No other ideas. Like I said I haven't worked with Cloud much and I'm not clear on the email handler situation there.

All I'd say is to look carefully at the documentation page:

https://confluence.atlassian.com/adminjiracloud/creating-issues-and-comments-from-email-779288896.html#CreatingIssuesandCommentsfromEmail-messagehandlers

Maybe something could be done using the "in-reply-to" header.

If Else January 12, 2021

"The only thing that scriptrunner can do for you is react to the ticket creation, check if a similar ticket exist, then delete or discard the newest one.  But any notification associated with the ticket creation or deletion will still take place."

thats exactly what i am trying to do too -  delete or discard. but how do I check if it already exists in the first place? i don't want to create issue with same summary. Please help.

Thanks

Like Srikanth Ganipisetty likes this
Srikanth Ganipisetty January 12, 2022

Interestingly, I have the same question exactly after an year on Jan 12th, 2022. Lol :) I will try the above scenarios and post the answer for new folks observing this need. 

Thanks, 

Srikanth Ganipisetty

Suggest an answer

Log in or Sign up to answer