Use JQL to locate issues in a script

This is an example script for when Profile’s Script Field Processor or Project Mapping: Script Rule is required to detect whether an issue can be located via JQL Query.


The following ECMAScript (JavaScript) code will run a JQL query to find an issue. The key of the first issue found in the results is set as a value for "issueKey" in the resultMap object. This "issueKey" directive would then ultimately direct JEMH to comment on the existing issue with the processed email. Note that this behaviour is just an example - you could do anything with the returned issue(s).

The below example would match against an issue that has all the following values:

Field A

Field B

Field C

Field A

Field B

Field C





Since JEMH 3.3.21 we lock down access to arbitrary classes in the script context, they cannot be accessed using historic methods:

var filter = PagerFilter.static.getUnlimitedFilter(); var builder = JqlQueryBuilder.static.newBuilder();

but need to be gained through fully specified class names:

var filter = Java.type("com.atlassian.jira.web.bean.PagerFilter").getUnlimitedFilter(); var builder = Java.type("com.atlassian.jira.jql.builder.JqlQueryBuilder").newBuilder();

These specific classes were not initially added, are available since JEMH 3.3.38

Due to issues highlighted on the following page, It means that if you are using Java 17 with Nashorn installed within jira-install/lib then you will need to use JEMH 4.1.33+ and then use the following instead of lines 4 and 5:

  • var filter = pagerFilter; var builder = jqlQueryBuilder;