How to create a simple "customfield-searcher"?

Dear community,

I am struggeling with a custom-searcher.

I’ve created my own customfield-type and it works fine. I am able to create new custom fields based on my type and add them on my screens. Values get saved and everything is good. Now i need them to search. By JQL, by Java and things like that. I’ve learned, that I need to build/implement a customfield-searcher.

Following is status qou. It produces no errors, but work not as aspected:

Like I said, I’ve created my own customfield-type:

  <customfield-type key="de.mycompany.com.jira.customfields.qualitygate"
                    name="Quality Gate Picker"
                    i18n-name-key="Quality Gate Picker"
                    class="de.mycompany.com.jira.customfields.FieldQualityGate">

    <description>Choose the Quality Gate which the issue belongs to.</description>
    <resource name="view" type="velocity" location="/templates/fieldqualitygate/view.vm"/>
    <resource name="edit" type="velocity" location="/templates/fieldqualitygate/edit.vm"/>

  </customfield-type>

So far so good. Then, I added a customfield searcher:

  <customfield-searcher key="qualitygatesearcher" name="Quality Gate Searcher" class="de.mycompany.com.jira.searcher.QualityGateSearcher">
    <description>Allow searching for Quality Gates</description>
    <ressource type="velocity" name="search" location="/templates/fieldqualitygate/searcher_search.vm"/>
    <ressource type="velocity" name="view" location="/templates/fieldqualitygate/searcher_view.vm"/>
    <valid-customfield-type package="${atlassian.plugin.key}" key="de.mycompany.com.jira.customfields.qualitygate"/>
  </customfield-searcher>

My customfield-searcher class is the following:

package de.mycompany.com.jira.searcher;

import com.atlassian.jira.issue.customfields.searchers.TextSearcher;
import com.atlassian.jira.issue.customfields.searchers.transformer.CustomFieldInputHelper;
import com.atlassian.jira.jql.operand.JqlOperandResolver;
import com.atlassian.jira.web.FieldVisibilityManager;

public class QualityGateSearcher extends TextSearcher
{
    public QualityGateSearcher(FieldVisibilityManager fieldVisibilityManager, JqlOperandResolver jqlOperandResolver, CustomFieldInputHelper customFieldInputHelper)
    {
        super(fieldVisibilityManager, jqlOperandResolver, customFieldInputHelper);
    }

}

The result is: no errors but also no function. If I try to search by the custom field by JQL in JIRA itself, the custom field can not be found.

My JIRA Version is 7.13.1

Can you help me? Do you have any idea what I am doing wrong?

Kind regards
Manuel

2 Likes

Hi Steven. Do you probably have an idea what i am doing wrong @sfbehnke ? :grimacing: I have no clue why it is not working. Greetings!

This is just a simple guess but make sure you do have the Searcher assigned to your Custom Field. When you click “Edit” (I think that’s the option name) in the Issue->Custom Field list, for your Custom Field.

Do you expect to see JQL Functions? You would need to create a subclass of AbstractJqlFunction and add it to your atlassian-plugin XML.

1 Like

I haven’t toyed with searchers much. If I have the chance to look into it I’ll respond back.