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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.