I need to create a CustomFieldType with a custom field customisation screen. If I try to create an instance of the default SingleSelectCustomFieldType, the field customisation screen will ask me to provide a name, an optional description and a list of possible values to be selected.
In the plugin I'm writing, I am going to define a new CustomFieldType (say MyCFT), and need to override this screen with a custom screen so that MyCFT instances may be configured the way I want (for instance, I may want to offer the user to select from a dropdown of projects instead of asking a list of possible values).
I tried to read the source for the existing CustomFieldTypes, but could only find the FieldResource class for the REST API, and no way to specify custom velocity templates or soy files for a specific CustomFieldType. Is this feasible or will require "hacks" in order to happen? Has anyone done that before?
Working on JIRA Server 7.4.2, if this helps. Thank you in advance.
Hello Jacopo,
You can do that, if I did not misunderstand the question.
First you have to create a ConfigItem class which should implement FieldConfigItemType (com.atlassian.jira.issue.fields.config.FieldConfigItemType)
The FieldConfig variable that is passed to the methods (that you should implement) represents the context of the custom field.
Also you should implement such a method
public String getBaseEditUrl() {
return "EditMyCFTConfig.jspa";
}
and this should be used in a webwork in your atlassian-plugin.xml file
<webwork1 key="mycftconfigaction" name="..." class="java.lang.Object">
<actions>
<action name="com...EditMyCFTConfiguration"
alias="EditMyCFTConfig">
<view name="input">/templates/customfield/mycft/edit-config.vm</view>
</action>
</actions>
</webwork1>
edit-config.xml is the file that you can design any way you want.
Sorry if it is complex, but the process itself is complex and you should read some documents to achieve that.
I hope this may give some clues.
Best
You're right, I finally found some related answers here but the search terms were actually more technical than what I searched. And yes, the process is actually complex and unfortunately not very well documented, so I'm still unsure of what are half of the methods I have to override supposed to provide :D
[EDIT] To be precise, the accepted answer is the way to go, but solves the problem in a different way. Using ConfigItems will NOT "add pages" after choosing name and description for your CustomField. Instead, it will ad a "default" configuration for your additional parameters that you then will have to manually edit by going to the CustomField configuration page and open the relevant WebWorks action page (that was indeed pointed out as the correct way to go). In my research I found no way to add pages to the "create custom field" wizard, therefore I must assume my original idea is unfeasible.
Thank you for your answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.