Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Associate Email to Issue via Custom Field Lookup (Regex + JQL)

G P N
December 16, 2025

I have a requirement. When I receive an email in the Jira Inbox from "test@mail.com" with the subject containing the string : test successful for {ABC12345678} 

body contains : test successful for {ABC12345678} 

It should add a comment to the parent ticket that has the {ABC12345678} value for the custom field. 

{ABC12345678} is a custom field value. How to fetch the issue key with this value.

Which approach is best: the Enterprise Email handler or the ScriptRunner Mail handler?

Any guidance, documentation, or examples would be incredibly helpful. Thanks for your time and expertise!

2 answers

0 votes
Sambar Khan
December 16, 2025

Jira’s default email handler is limited. It can only act when the issue key is already present in the email subject. It cannot extract a value using regex, search a custom field using JQL, and then decide which issue should receive the comment.

With ScriptRunner, this flow is supported:

Extract {ABC12345678} from the subject or body using regex

Use that value in a JQL search against the custom field

Identify the matching parent issue

Add the email content as a comment

This is a standard use case for ScriptRunner custom mail handlers. The official documentation with examples is available here and opens correctly:

Mail Handlers

That page explains how to build custom mail handlers and how to run JQL inside them, which fits your scenario exactly.

If the issue key is not present in the email, ScriptRunner is the safest and m

0 votes
Hari Krishna
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
December 16, 2025

Hi @G P N ,

For this kind of requirement, ScriptRunner’s Mail Handler is the better fit.

The built-in Jira (Enterprise) email handler is really meant for simple scenarios only — things like creating a new issue from an email or adding a comment when the issue key is already in the subject. Once you go beyond that, it starts to fall short.

In your case, you need to:

read a value from the email using a pattern,

search Jira using that value in a custom field,

and then decide what to do based on the result.

That kind of logic just isn’t something the standard email handler can do. ScriptRunner is designed exactly for these situations and gives you the flexibility you need to make this work reliably.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events