How to get all issues(regardless of projects) assigned to a user

I need to set due date automatically based on the original estimate if:

  1. Issue has been assigned to a user
  2. Issue has an original estimate

For this, I need to get all the issues assigned to the user so that I can see what open issues he/she has sorted by their priority. How do I get all the issues assigned to a user?

The short answer is JQL:

assignee IN (currentUser()) ORDER BY priority DESC

Which you can issue through the JIRA REST API’s search endpoint. Here’s a Bash example using HTTPie:

#!/usr/bin/env bash
PAYLOAD=$(cat <<EOF
{
    "jql": "assignee in (${TARGET_USER}) ORDER BY priority DESC"
}
EOF
)

echo "${PAYLOAD}" | http -a ${JIRA_USERNAME}:${JIRA_PASSWORD} \
    POST ${JIRA_BASE_URL}/rest/api/2/search
1 Like

Wait, wow wow wow. What was that, man? (:fearful:) How do I plug the JQL above to the below code?

    @EventListener
    public void onIssueEvent(IssueEvent event) throws Exception{
        MutableIssue issue=(MutableIssue)event.getIssue();
        ApplicationUser currentUser=ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

       //Find the issues assigned to the current user.

        
    }

It looks like you’re building a Java plugin so you’ll need to refer to the Java API, as opposed to the REST example I provided earlier.

There’s an example of using JQL to search in jira-report-plugin. The searchMapIssueKeys method demonstrates how to use the SearchProvider class. This search method takes a query, user, and a paging strategy, if you don’t care about sorting.

1 Like

Thanks a lot @ibuchanan. In fact, later your JQL hint alone was enough for me to get up and running. This link has a similar code that does just what I need.