create custom field for any issue type


I am creating a custom field in a plugin and trying to add a custom field searcher for it , both on plugin installation.

On creating custom field I would like it to be availavle for all issue types and I'm getting them like following:

List<GenericValue> issueTypes = new ArrayList<GenericValue>();
Collection<IssueType> list = constantsManager.getAllIssueTypeObjects();
for (IssueType issueType : list) {
try {
	CustomField cf = customFieldManager.createCustomField(name, "", selectFieldType, fieldTypeSearcher,
	contextTypes, issueTypes);

	return cf;
} catch (GenericEntityException e) {
	return null;

Indeed after plugin is installed under custom field configuration part I see that each issue type (except for story) is selected, but I would like "any issue type" to be selected instead. Unfortunately searcher is not set for the custom field and I have to set it under 'custom field edit'. After that when I try to search by custom field it is hidden before I select exact issue type in the search.

And when I configure it manually for "Any issue type" then it's not hidden even if I don't select any other criteria.

Does anybody know

1. How can I make "Any issue type" selected on custom field configuration from java code, instead of each type selected?

2. Is it possible to set searcher for the custom field from java, so I don't have to do it manually after plugin installation? I have managed to do this from a class registered in atlassian-plugin.xml webwork action, but it's not working from class registered under <component.../> When I try to do it in the same way, as customFieldManager.getCustomFieldSearcher(typeKey), I'm getting InvocationTargetException in second (<component...>) case

Appreciate any help,


1 answer

1 accepted

1 vote
Accepted answer

1. You have to add null.

//Create a list of issue types for which the custom field needs to be available
        List&lt;GenericValue&gt; issueTypes = new ArrayList&lt;GenericValue&gt;();

2. You can pass the key directly.

See for both. It shows creation of custom field with a searcher.


Thank you very much for your quick answer.

I'm not quite clear what I was doing wrong for the second question, since I have tried this before and was getting InvocationTargetException . Maybe implementing the first fix influenced the second as well.

Anyways, I have implemented both changes and they works excelent!

Thanks again :) ,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

460 views 8 27
Read article

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