List<Issue> getIssuesFromProject(Long projectId) throws SearchException { JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().project(projectId); builder.orderBy().addSortForFieldName("STRINGVALUE", SortOrder.ASC, true); Query query = builder.buildQuery(); SearchResults results = ComponentManager.getInstance().getSearchProvider().search(query,ComponentAccessor.getJiraAuthenticationContext().getUser(), PagerFilter.getUnlimitedFilter()); return results.getIssues(); }
In above codei want to get issue for given project ID and order by customfield value in asccending order.
"STRINGVALUE" is the column name of customfieldvalue table of jira where value of customfield store
but its not working can anyone tell me what is wrong in it or is any other way to get issue orderby of value of customfield
just try with
builder.orderBy().add("your customfield name",SortOrder.ASC);
Hi Bharadwaj
i try this but its not working
List<Issue> getIssuesFromProject(Long projectId) throws SearchException { final CustomField customField1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("WBS"); JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().project(projectId); //builder.orderBy().issueKey(SortOrder.ASC); builder.orderBy().add("WBS" , SortOrder.ASC ,true); //builder.orderBy().addSortForFieldName("STRINGVALUE", SortOrder.ASC ); //builder.orderBy()("STRINGVALUE", SortOrder.ASC,true); Query query = builder.buildQuery(); SearchResults results = ComponentManager.getInstance().getSearchProvider().search(query,ComponentAccessor.getJiraAuthenticationContext().getUser(), PagerFilter.getUnlimitedFilter()); return results.getIssues(); }
in this WBS is my customfield name
WBS field Contain
1
2
3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok Sachin, is it throwing any error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
List<Issue> getIssuesFromProject(Long projectId) throws SearchException { JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().project(projectId); builder.orderBy().add("FIN" , SortOrder.ASC ,true); Query query = builder.buildQuery(); SearchResults results = searchService.search(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),query, PagerFilter.getUnlimitedFilter()); return results.getIssues(); }
in my constructor I wrote like this to get searchService
import com.atlassian.jira.bc.issue.search.SearchService;
public EditLink(SearchService searchService){ this.searchService=searchService; }
this worked for me and FIN is of select list type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
also go through the code for searchService in
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In JQL you would not order by the name of the custom field, rather by the custom fieldID. This would look something like "ORDER BY cf[10100] ASC" where the value of cf[] determines which custom field is being used.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
but Mick how we use this custom field ID in this syntax.
builder.orderBy().addSortForFieldName("STRINGVALUE", SortOrder.ASC, true);
Means where we mention customfield ID in orderBy() method
Can you modify above code with corrected code according to requirement
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.