Chapter 2. Custom Field Types

Overview

This chapter describes how to create your own custom field type using a JIRA plugin. The basics of creating, building and deploying any kind of JIRA plugin were described in Building and Deploying a Plugin. The complete source code for the examples in this and other chapters is available from https://marketplace.atlassian.com/41293.

A New Custom Field Type

Each custom field in a JIRA issue has a particular custom field type. When a JIRA administrator creates a new custom field the available custom field types are shown, e.g., Free Text or Select List. To see a new custom field in a JIRA issue, the administrator has to create a custom field of the chosen type and also make sure that it is associated with the desired projects, issue types and screens.

Our example is a new custom field type for currency values. This type of custom field is something for which there are several long-standing feature requests at Atlassian, e.g., JRA-3873. We’ll start off with just one currency, whatever the local one is for the Java JVM used by JIRA. Then we’ll add more features after that.

The first thing to consider is whether we can build on an existing JIRA custom field type. These standard types are defined in the JIRA file system-customfieldtypes-plugin.xml. Since the data we want to store is a number, the best class to extend for this example is the com.atlassian.jira.issue.customfields.impl.NumberCFType class, which is what is used by the standard Number Field ...

Get Practical JIRA Plugins now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.