|
This example is tested in JIRA 3.6.5. It searches issues which match the search term of a given CustomField. User you = ((JiraAuthenticationContext) ComponentManager.getComponentInstanceOfType(JiraAuthenticationContext.class)).getUser(); SearchProvider sProvider = (SearchProvider) ComponentManager.getComponentInstanceOfType(SearchProvider.class); SearchRequest sRequest = new SearchRequest(you); CustomFieldManager cfm = ComponentManager.getInstance().getCustomFieldManager(); CustomField cf = cfm.getCustomFieldObject("customfield_10021"); IssueSearcher searcher = cf.getCustomFieldSearcher(); FieldValuesHolder fvh = new FieldValuesHolderImpl(); CustomFieldParams cfp = new CustomFieldParamsImpl(); List list = new ArrayList(); list.add("hello"); cfp.put(null, list); cfp.setCustomField(cf); fvh.put("customfield_10021", cfp); searcher.populateSearchRequest(sRequest, fvh); List searched = sProvider.search(sRequest, you, PagerFilter.getUnlimitedFilter()).getIssues(); |

Comments (1)
Dec 12, 2007
Joshua Goodall says:
If you know the parameters that the searcher uses, then this simplifies to (for ...If you know the parameters that the searcher uses, then this simplifies to (for example, a Resolution Date CF from the Charting plugin):
Those in possession of the Java source of JIRA will find the hint of which parameter to use inside the populateSearchRequest of the relevant searcher class.
To discover the relevant searcher class, peek inside the customfield's XML descriptor - the class attribute of the customfield-searcher element. You'll find that in system-customfieldtypes-plugin.xml for the JIRA distribution, or the atlassian-plugin.xml inside a plugins jarfile.