I have created a new issue field called "Business Driver" of field type "Labels". It works, but when I try to search for issues where has a specific value for "Business Driver", Jira instead searches the "Labels" field. This is a known issue, as per the Jira docs.
To get around this, I'm trying to create a new customfield-searcher to associate with the field. Since the functions are 99% the same as the existing "labelsearcher" customfield-searcher, I figured that I could pretty much clone the entry in system-customfieldtypes-plugin.xml and point the labelsearcher at a new customfield-searcher and avoid having to write a new Java class. Sadly, this seems to not be the case.
The original code for the label searcher is as such:
<customfield-searcher key="labelsearcher" name="Labels Searcher" i18n-name-key="admin.customfield.searcher.labels.name" class="com.atlassian.jira.issue.customfields.searchers.CustomFieldLabelsSearcher"> <description key="admin.customfield.searcher.labels.desc">Search for values matching labels.</description> <resource type="velocity" name="label" location="templates/plugins/fields/view-searcher/label-searcher-label.vm"/> <resource type="velocity" name="search" location="templates/plugins/fields/edit-searcher/search-basictext.vm"/> <resource type="velocity" name="view" location="templates/plugins/fields/view-searcher/view-searcher-basictext.vm"/> <valid-customfield-type package="com.atlassian.jira.plugin.system.customfieldtypes" key="labels"/> </customfield-searcher>
My code is deeply similar. I've changed the key and the name in the hope of getting Jira to search the Business Driver field as if it was a label:
<customfield-searcher key="businessdriversearcher" name="Business Driver Searcher" i18n-name-key="admin.customfield.searcher.businessdriver.name" class="com.atlassian.jira.issue.customfields.searchers.CustomFieldLabelsSearcher"> <description key="admin.customfield.searcher.businessdriver.desc">Search for values matching Business Driver.</description> <resource type="velocity" name="label" location="templates/plugins/fields/view-searcher/label-searcher-label.vm"/> <resource type="velocity" name="search" location="templates/plugins/fields/edit-searcher/search-basictext.vm"/> <resource type="velocity" name="view" location="templates/plugins/fields/view-searcher/view-searcher-basictext.vm"/> <valid-customfield-type package="com.atlassian.jira.plugin.system.customfieldtypes" key="labels"/> </customfield-searcher>
The result is that in "Edit Custom Field Details" screen I have a new option for the Search Template for Business Driver. The new template is called "admin.customfield.searcher.businessdriver.name", which corresponds to the value of i18n-name-key. This leads me to believe that this is not quite as straightforward as I'd hoped. It would seem that either I need a new class that has 99% of the functions of the existing CustomFieldLabelsSearcher class, extend CustomFieldLabelsSearcher to search Business Driver, or update the package com.atlassian.jira.plugin.system.customfieldtypes to include a new key for my new field. All of these solutions seem really involved for what would seem to be a simple modification. Is there an easier way to do this? Am I making the problem more complex than it needs to be?
Note: I'm using Jira 4.2.2 standalone.
Community moderators have prevented the ability to post new answers.
yup, just remove the i18n key. Also have a look at http://www.j-tricks.com/1/post/2010/09/custom-field-searchers.html for some tips.
Why dont just create a filter using jql?
"Business Driver" = "Your Search"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That would be the logical solution, yes, but it doesn't work. If you create a graph or a chart based on a JQL filter specifying "Business Driver", then try to bring up the list of issues generated by the chart I get the behavior described above. It's a long way to go for such a simple thing but I don't see a solution other than writing a custom searcher.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still looking for an answer on this one. Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What you did above was define a new searcher but it was still using the same Java class com.atlassian.jira.issue.customfields.searchers.CustomFieldLabelsSearcher so it was still doing the same (wrong) thing and searching only in the system Labels field.
Is there a known bug about this? That link was just to a docs page about labels.
~Matt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not familiar with searchers but you might want to look at some sample code if you have familiarity with Java and JIRA development.
Does you field have to be of "Labels" type? Can you use some other custom field type such as Select or multi select? Maybe that could make it easier as those kinds of fields will be searched separately from any other labels field.
Btw, If you remove "i18n-name-key", JIRA will probably show the "name" attribute.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.