Build a searcher for a complex custom field

I am working on my first Custom Field Type add-on.  I want to build something called "Business Value", which is the summation of multiple dropdown values.  I have successfully created the Custom Field Type that takes in 4 inputs, and creates a single output.  The 4 inputs are maintained in the database and the single output is calculated for the view.vm and the column-view.vm.  

But I cannot seem to figure out how to get this searchable and sortable.  I know I need to extend/implement one of the searchers, but I cannot seem to figure out how to get my summed final value to be the thing it is searching on.  So how do I get my sorter to do a lookup of a CustomFieldType.

Thanks in advance

1 answer

1 vote

Hi Mike,

 I found a portion of the Custom field documentation that may help.  There is a section titled Adding searching to a custom field that may be of use:

Custom fields need a custom field searcher before you can search them in the Issue Navigator. If a custom field type is a going to behave somewhat like an existing type, then you can reuse an existing searcher. For example, if you’re creating a custom field type that’s like a multi select list and want to reuse the default multi-select searcher, you could add the block below to your atlassian-plugin.xml (taken from system-customfieldtypes-plugin.xml)

<customfield-searcher key="multiselectsearcher" name="Multi Select Searcher"
    i18n-name-key="admin.customfield.searcher.multiselectsearcher.name"
    class="com.atlassian.jira.issue.customfields.searchers.MultiSelectSearcher">
    <description key="admin.customfield.searcher.multiselectsearcher.desc">Search for multiple values using a single select list.</description>

    <resource type="velocity" name="search" location="templates/plugins/fields/edit-searcher/search-multiselect.vm"/>
    <resource type="velocity" name="view" location="templates/plugins/fields/view-searcher/view-searcher-multioption.vm"/>
    <resource type="velocity" name="label" location="templates/plugins/fields/view-searcher/label-searcher-basictext.vm"/>
    <valid-customfield-type package="YOUR CUSTOM PACKAGE" key="YOUR CUSTOM FIELD KEY"/>
</customfield-searcher>

 

which will enable searching for any text based, multi-select custom field type. When creating the custom field, you will now be able to select the multi-select searcher and your custom field should then be displayed in the Issue Navigator.

Note that “YOUR CUSTOM PACKAGE” refers to the package (ie. the module key) of the custom field that the searcher applies to, which is the “key” attribute of the top-level atlassian-plugin element. “YOUR CUSTOM FIELD KEY” refers to the “key” attribute of the customfield element.

Notes

Types and searchers can be combined in different ways to produce new custom fields, for example a “user” custom field could take a simple text searcher (to enter the username as text) or a more complex “user picker searcher” (where the user is picked from a popup window).

Hopefully that helps.

 

Notes

Types and searchers can be combined in different ways to produce new custom fields, for example a “user” custom field could take a simple text searcher (to enter the username as text) or a more complex “user picker searcher” (where the user is picked from a popup window).

Cheers,

Branden

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

421 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you