The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

query building with custom fields using JqlQueryBuilder

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 19, 2013

I have an existing builder as follows which is working in JIRA retriving issues.

JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
builder.where().and().assigneeUser(user.getName());
builder.where().or().reporterUser(user.getName());

I have a custom field(id is 10000) that stores user object. Now I want to add this custom field to the builder object which is similar to assignee, reporter using or operator. How can i do that?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 19, 2013

try with this code

CustomField cf = customFieldManager.getCustomFieldObjectByName("CustomField Name");	
User cfValue=(User)issue.getCustomFieldValue(cf );	
JqlClauseBuilder builder = JqlQueryBuilder.newClauseBuilder();
Query query = builder.customField(cf.getIdAsLong()).eq(cfValue.getName()).buildQuery();
SearchProvider searchProvider = ComponentAccessor.getComponentOfType(SearchProvider.class);
SearchResults searchResults = searchProvider.search(query, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),PagerFilter.getUnlimitedFilter());
List<Issue> issues = searchResults.getIssues();

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 20, 2013

Thank you Prasad. With minor changes to your code, I am able to add JqlClauseBuilder to my JqlQueryBuilder object.

TAGS
AUG Leaders

Atlassian Community Events