On {JIRA_GOME}/scripts/ create this folders:

For example: ../jira_home/scripts/com/onresolve/jira/groovy/jql

Then add the groovy file with the new JQLFunction, exmaple: HasInactiveAssignee.groovy

The code:

package com.onresolve.jira.groovy.jql

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.operand.QueryLiteral
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.jql.query.RangeQueryFactory
import com.atlassian.jira.util.MessageSetImpl
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.operand.FunctionOperand
import com.atlassian.query.operator.Operator
import org.apache.log4j.Category
import com.atlassian.jira.util.MessageSet
import com.atlassian.crowd.embedded.api.User
import com.atlassian.query.clause.TerminalClause
import com.atlassian.jira.jql.query.QueryCreationContext
import org.apache.lucene.document.NumberTools
import org.apache.lucene.index.Term
import org.apache.lucene.search.Query
import org.apache.lucene.search.TermQuery
import com.onresolve.jira.groovy.jql.AbstractScriptedJqlFunction
import org.apache.lucene.search.BooleanClause
import org.apache.lucene.search.BooleanQuery
import org.apache.lucene.search.Query
import org.apache.lucene.search.TermQuery
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.security.JiraAuthenticationContext;

class HasInactiveAssignee extends AbstractScriptedJqlFunction implements JqlQueryFunction{
    String getDescription() {
        "Function to show only the inactive users"

    List<Map> getArguments() {
                "description": "Subquery",
                "optional": false,

    String getFunctionName() {

    def String subquery
    MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) {
		 def messageSet = new MessageSetImpl()
		 return messageSet

    Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {
		 //User user=ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
		 JiraAuthenticationContext context = ComponentAccessor.getJiraAuthenticationContext();
		 ApplicationUser applicationUser = context.getUser();
		 def booleanQuery = new BooleanQuery()
		 issues = getIssues(operand.args[0], applicationUser)
		 issues.each {Issue issue ->
								def active = issue.assignee.isActive()
								if ( !active )
                                booleanQuery.add(new TermQuery(new Term("issue_id", issue.id as String)), BooleanClause.Occur.SHOULD)
                        }catch(NullPointerException NPE){
        return booleanQuery

Then Go to Addons –> ScriptRunner –> Script JQL Functions –> and then press “Scan”

Syntax:  issueFunction in hasInactiveAssignee(‘project = XXX’)

That’s all!

Posted by:.

14 replies on “New JQL Function Custom to retrive issues with inactive user in assignee “HasInactiveAssignee” or in reporter “HasInactiveReporter” (Jira 6 and 7)

  1. Just as a quick FYI – I’m running JIRA 6.3.11 and Crowd 2.4.2 and within the Script Runner, Script JQL Functions area, I see the below warning:

    use JiraAuthenticationContext.getUser(). Since v6.0 @ line 64, column 11.

    However, it still seems to work.

    Will this change for JIRA 7.0?

    Liked by 1 person

  2. You can replace this line:
    “User user=ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();”
    for this one:
    “User user=ComponentAccessor.getJiraAuthenticationContext().getUser();”
    because the method is deprecated 😛 sorry


    1. I had tried that, however it gave another error. Will this not work for folks using Crowd and JIRA?

      [Static type checking] – Cannot assign value of type com.atlassian.jira.user.ApplicationUser to variable of type com.atlassian.crowd.embedded.api.User
      @ line 64, column 11.


  3. OK, I think is something related to use Crowd or not ( my script is for crowd users).
    I am reading the documentation for the class in JIRA 7 and it seems work fine.

    In other words:
    getUser() is Deprecated.
    Use getLoggedInUser(). Since JIRA v7.0 (but you can use in JIRA 6 also)



  4. @IncompatibleReturnType(since=”7.0″,
    ApplicationUser getLoggedInUser()
    Returns the currently logged in User.
    Warning: previous incarnations of this method returned com.atlassian.crowd.embedded.api.User. This method had previously been deprecated and has been reused to return an ApplicationUser instead. That class has different semantics for Object.equals(Object) and therefore does not extend the User class. This means that the 6.0 version is not binary or source compatible with earlier versions when this method is used.

    The logged in ApplicationUser, or null


  5. Hi Carol, now I am testing the function for JIRA 7 and needs some changes in the source:
    – Remove/Comment @Override in the validate() function
    – Remove/Comment User user=ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

    I am testing and now works fine with JIRA7



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s