Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Add to customfield (single select drop down) from customfield (single line text field) scriptrunner

I've been trying to wrap my head around this.  We have a custom single line text field that our users enter data into.  This data would like to be used in a statistical view.  My understanding is the only way to do this is to have this custom field add each value as a option in a drop down custom field.  How would one go about automating this? I've read thru the groovy documentation and just can't seem to figure this one out,  does someone have a script they could share to do this? 

customfield_710 text add entered value as option to customfield_810 drop down

Thanks in advance.

1 answer

0 votes

Yes, that's right, to do stats, you need fields that can be indexed from a list of options.

I've done what I think you want a couple of times in the past - specifically setting up a Jira project that was for admins to track all the work, and change, on their Atlassian applications, and we did obvious stuff like "request project from template, authorise, automatically create", but also "this field's list of options is maintained by people updating a Jira issue" - stuff like "add new option please, fill in a text field with new name, click ok, and a post-function adds the option"

There's two things you'll need to look at if you do it that way. 

First, there's the actual option - the starting point there is the OptionsManager class - it's the main thing that handles options, and has calls like createOption, getAllOptions and so-on.  

Second, you'll need to consider permissions.  In my example, it was not Administrators running the post-function, so my script needed to take on the role of an admin while it was trying to call the createOption function.

I've not seen any recent examples (my code was for Jira 3, and long since forgotten which old disk I might have kept a copy on), but the Java API is over at - use frames and the left-bar to find OptionsManager docs

Thanks was hoping someone had an example we could work with rather than reinventing the wheel.  Thank you.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events