Hello. I'm using Jira Data Center v8.20.
Will someone please provide the Scriptrunner code (including the import statements) for adding options to a drop-down list.
I haven't seen much online that shows me how to do this. I saw something like a 'setoptions' or 'setFieldOptions' method somewhere but can't find it anymore.
Either way, everything I've tried doesn't work. Either there's no method for my field declaration, at least no method that makes sense to me to set the options, or I'm declaring my drop-down field incorrectly.
Note: The code can't refer to an issue because the issue has not yet been created. I'm trying to populate the drop-down list at the point where the initial issue screen is open for user input (before the issue is actually created).
Scenario of what I'm trying to do:
When a user opens an issue, only specific projects that belong to them will be listed as options to select.
Example: If user Mark opens an issue, the drop-down list will be populated ONLY with projects 'M1', 'M2', and 'M3'. User John's drop-down list will only include 'J1', 'J2', 'J3'.
I know the logic for this. I'm using case statements. (i.e., case reporter = "Mark" --> drop-down list items = [Mark's projects]). I only need the code for dynamically setting the options in the drop-down list.
Recap:
1. I have a single select drop-down list (custom field). When creating it, I only included one option called 'None' in order to create the field. The other options need to be filled dynamically when the user opens an issue.
2. The code can't refer to an issue because one hasn't yet been actually created.
Than you in advance.
Hi @Mark Johnson ,
welcome to the Atlassian Community!
I don’t think your approach is correct. I believe what needs to be done is to add all possible options to your custom field and hide some options using Behaviours, when the user opens the form.
Almost the same thing is done here:
Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.
Register here ⬇️Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.