Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
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.
Nov 05, 2021

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 https://docs.atlassian.com/software/jira/docs/api/8.13.13/ - 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
TAGS
AUG Leaders

Atlassian Community Events