Applying multiple filters when retrieving values from a JIRA database

Hi,

I'm developing a JIRA plugin that connects to a JIRA database and retrieves values. I use the following line to filter the issues based on issue assignee, if I want to add another filter to this, how should I modify it?

List<GenericValue> issues = delegator.findByCondition("Issue", new EntityExpr("assignee",EntityOperator.EQUALS,"abc"), EasyList.build("id","key","assignee","status"));

In sql terms it should be something similar to "select id, key, assignee, status from jira_issue where assignee='abc' and status='resolved'".

Any help would be much appreciated.

Thanks.

1 answer

1 accepted

This widget could not be displayed.

You can create a filter with your search criteria and use it to retrieve the issue. If you use thismethod , if later you want to change the search criteria no need to change the code .

ex: final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();

builder.where().savedFilter().eq(new Long(activeEmployeeFilterId))

Hope this may help you

Hi,

could you please explain a bit more, Im relatively new to JIRA development so its a little unclear. How do I define the activeEmployeeFilterId in the java class of my plugin and how can I access the values retrieved by the filter? What I need to do is to retrieve the issues and filter them based on the assignee and status and reassign the issue. In order to do this I need to filter issues based on two selection criteria.

Thank you for the prompt response

You can create filters in Jira. For each filter it will assign id.

ex:- you have created a filter called all active employees and filter id is 10000

final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();

builder.where().savedFilter().eq(new Long("10000")) // this will give the same results as the filter you created.

If you want to add more condition to this you can add as follows.

builder.where().savedFilter().eq(new Long("10000"))

.and().customField(field1.getIdAsLong()).eq(field1value)

.and().customField(field2.getIdAsLong()).eq(field2value);

means you can add more conditions on the filter and the get result.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

131 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you