Make custom field configurable

Mokuyobi February 24, 2013

Hey,

I wrote a new custom field type. I want now to create multiple fields of it which different permissions. Like: One instance is only modifyable by projectRole "A" the second only by projectRole "B". (Yes it could be done by duplicate the plugin and set the different roles in the code but thats to static. It should be easy to modify the roles by admins even if they do not know the jira plugin sourcecode)

I saw some ways with WebWorker Plugins and DAO (Data Access Objects). So I created a WebWorker Plugin Site for editing the projectRole. The Webworker plugin contains a form and a select-tag containing all projectRoles - works fine.

Now the problem is how to setup the DAO. I searched and found some stuff about PropertySet and Active Objects. But I do not understand how to merge now one of these to my customfieldtype. Is there any practical tutorial on how propertyset or active objects works?

2 answers

1 accepted

3 votes
Answer accepted
JamieA
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.
March 20, 2013

Check out the source code which accompanies @Matt Doar's Practical JIRA Plugins book. The source is available on marketplace.

It has a nice example of how to do this.

Gert-Jan van de Streek
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.
March 20, 2013

Thanks Jamie, I will have a look at that.

Gert-Jan van de Streek
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.
March 20, 2013

Thanks Jamie, found what I need there. To sum it up quickly:

  • Create an implementation for the interface FieldConfigItemType
  • In the custom field type override the method getConfigurationItemTypes

The relevant example from the book Jamie mentions is configurablecurrency

This gives you a configurable custom field, which means that if you need that same custom field type in another configuration you have to add a second custom field.

JamieA
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.
March 20, 2013

> which means that if you need that same custom field type in another configuration you have to add a second custom field

Not really, you should just add another field config, but you still have one instance of the custom field.

Gert-Jan van de Streek
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.
March 21, 2013

You are right. The only catch for me here is that I want it for 2 issue types in the same project. For whatever reason jira won't let me configure that. It looks like I am stumbling onto the same problem as described here.

Mokuyobi March 21, 2013

Hi Jamie, thanks for the answer, I will give it a try later :)!

Alexej Geldt
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.
July 4, 2013

@Jamie

Its a nice tutorial for a single field property, which is fine. But what if i wanted to set more then one property in a single step. I.E. filling a form with 4 values and saving it only once.I was unable to do that from mdoars tutorial because there is single fieldconfig context and a single entity.It does not allow to store multiple values.

mdoar also uses the propertySet technique. This turnes out in extremely nasty and confusing code. To be honest, i dont understand all of it. Its not mdoars fault, propertySet is just nasty. I was unable to do the same thing using active objects.

0 votes
Gert-Jan van de Streek
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.
March 20, 2013

Did you find a good solution for this?

Suggest an answer

Log in or Sign up to answer