create custom field for any issue type

Hi,

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) {
	issueTypes.add(issueType.getGenericValue());
}
...
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,

Dragica

1 answer

1 accepted

1 vote

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;();
        issueTypes.add(null);

2. You can pass the key directly.

See http://www.j-tricks.com/1/post/2012/03/plugin-lifecycle-events.html for both. It shows creation of custom field with a searcher.

Hi,

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 :) ,

Dragica

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

116 views 0 4
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