You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.
Join groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
How to select one of the existing value of dropwdown(single list dropdown) using groovy script?
Community moderators have prevented the ability to post new answers.
There is an example of how to select a value from a single select dropdown here using behaviours.
Essentially the server side script you want is:
import com.atlassian.jira.component.ComponentAccessor import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript @BaseScript FieldBehaviours fieldBehaviours def formField = getFieldByName("Single Select") def optionsManager = ComponentAccessor.getOptionsManager() def customFieldManager = ComponentAccessor.getCustomFieldManager() def customField = customFieldManager.getCustomFieldObject(formField.getFieldId()) def config = customField.getRelevantConfig(getIssueContext()) def options = optionsManager.getOptions(config) def optionToSelect = options.find { it.value == "The option to select here" } formField.setFormValue(optionToSelect.optionId)
You will need to change the field name and option to select.
Here is code exmple:
for(Option option: ComponentAccessor.getOptionsManager().getOptions(postroenie_cstFld.getRelevantConfig(issue))) if(option.toString().equals("option name")) { requaredOption = option; break; }
More details:
Options set is determinated with context, namely with project and issue type. Since it is requred to get option for some context. Then it is requred to find option wit requred name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This worked Perfectly.
But how i can set dropdown value to "None" which is the initial value of dropdown
I believe formField.setFormValue(-1) should set to None.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.