Troubleshooting JQL Functions
This page covers some issues users may face when using ScriptRunner JQL functions:
- JQL function isn't returning any results / JQL function isn't appearing
- IssueFunction is not available due to indexing problems
If you're not sure where to start with JQL Functions or are in need of a quick search filter, try our ScriptRunner JQL AI.
JQL function isn't returning any results / JQL function isn't appearing
If you use multiple plugins to alter JQL functionality, you may encounter a case where function names are the same in each plugin. There are several plugins such as Power Script and JQL Tricks which use the same function names such as hasAttachments() and subtasksOf(). As the keys for these plugins appear first alphabetically, their functions take precedence over ScriptRunner functions, as designed by Atlassian.
In cases where function names clash, you need to disable a function because the two plugins essentially cancel each other out. For example, if two plugins use the function subtasksOf() you need to disable one to be able to use the other.
Verify the problem
Workaround
If you want to use both plugins you need to disable the clashing JQL function module for one of the plugins. To disable a module proceed as follows:
issueFunction is not available due to indexing problems
Most ScriptRunner JQL functions work by using a custom field called issueFunction. This field is managed (locked), so it can't be on any screen and has a global context.
The Lucene indexers associated with issueFunction maintain the index data that allows the ScriptRunner JQL functions to work.
In extremely rare circumstances, Jira decides that the issueFunction field is not in scope for particular issues despite its global scope. This can result in problems with the affected issues either incorrectly appearing in the results of queries (such as linkedIssuesOf), or being missed from those results.
It appears that the issue in recognising issueFunction as a global custom field is due to a referential integrity problem in Jira's database, which could be caused by another plugin, or perhaps direct database edits.
Verify the problem
You can verify if Jira considers issueFunction out of scope by running the following script in the Script Console. Update ABC-1 in the script below to reference an existing issue you suspect is not being reindexed. If this script returns true, then reindexing is not the problem. If it returns false, follow the instructions in the workaround below.
Workaround
The workaround is to delete the issueFunction field using a script, disable then enable the ScriptRunner plugin, and then re-index Jira. When the plugin starts it will recreate this field.
Deleting and recreating the field will not cause any problems. However, you should do a full re-index after this process, so that we can index any issues that have been missed during the time this wasn't working correctly. At any stage feel free to contact support.
If you know which projects are affected, you can re-index specific projects rather than the entire Jira instance.