Develop a custom field plugin in JIRA

gil February 1, 2018

I wonder if I could develop a JIRA custom field plugin (of Version type), which will be able to sort the Version list when it is displayed for view or editing.  Also, can I put in additional logic to the field edit to control / validate its content before it can be saved to the JIRA issue.  Thanks.

1 answer

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2018

Yes, you can do all that in a custom-field plugin. Check out https://developer.atlassian.com/server/jira/platform/custom-field/

gil February 2, 2018

Hi Jobin,

Thank you for your reply.  I am reading thru your book on this topic and have few questions:

1. My custom plugin needs to extend the version field type.  In the velocity file, what HTML type do I use to display this Version type input box?

2. Continuing from #1, how do I sort the versions and display them in that input field?

3. How do I perform input validation on this version so that he data can be saved only when the conditions are met?

thanks.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2018

I don't know where to start because there can be a lot of different things to you can do, mainly because it has nothing to do with JIRA plugins. It is all about the UI experience :)

Keeping that in mind, you might want to look for some Ajax plugins that will retrieve all versions and show it in a user friendly way and allow sorting.

For #3, it depends on the conditions. You can do the validation on the UI itself or you can do some validation in the custom field type class.

gil February 2, 2018

So, in the customfield, I want to show only the versions that have not been selected in other JIRA issues, and I want to sort the versions when the selected ones are displayed in the customfield.  I need to be able to enforce this validation in the create/edit screen of the issue, and ideally in bulk update too.  What's the best way to do this  - develop a custom field or use AJAX / UI validation?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 3, 2018

The "versions not selected" is a nightmare to try in AJAX, and injecting javascript into a Jira UI is the second worst thing you can possibly do to customise a Jira system. 

Do this with a custom field.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2018

Just to clarify, I meant AJAX in the edit template of the new custom field type. Not by injecting javascript to the existing version field. Definitely new field type but it is up to you what you do in the edit html ;)

gil February 3, 2018

Thank you for the tips.

gil February 3, 2018

Also, if I implement the validation in the class, I know we can use this method:

validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)

 

So the logic is computed inside this method, and returning true/false will tell JIRA to save the data or not?  Can I have an example?  Thanks!

Suggest an answer

Log in or Sign up to answer