Hello world,
i've set up a behaviour for two option lists. Depending on the option in the select list "Strategic objective" the select list "Initiatives" shows corresponding options. My script works, but the select list (Inititatives) updates by clicking the list. How can I set up my code to get the list updated whenever a option is selected in the list "Strategic objectives" - on-action.
my code:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def strategicObj = getFieldByName("Strategic Objective")
def initiative = getFieldByName("Initiative")
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def strategicValue = strategicObj.getValue();
if (strategicValue == "1 - Example")
{
def optionsMap = options.findAll {
it.value in ["1.1 - XXX",
"1.2 - XXX",
"1.3 - XXX",
"1.4 - XXX",
"1.5 - XXX"] // list of options
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
initiative.setFieldOptions(optionsMap)
initiative.setRequired(false)
initiative.setHidden(false)
}
else if (strategicValue == "2 - Operative Exzellenz steigern")
{
def optionsMap = options.findAll {
it.value in ["2.1 - YYY",
"2.2 - YYY",
"2.3 - YYY",
"2.4 - YYY"]
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
initiative.setFieldOptions(optionsMap)
initiative.setRequired(false)
initiative.setHidden(false)
}
kr,
vedat
ScriptRunner works only after you selected an option in the list, not in the process. I guess, you can not change it.
Isn't it, at least, possible to change the values after I've selected an option instead of clicking in the field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not sure, I understand your question. First, you need to add the Strategic Objective field to your behaviour. Then your attach your script to the added field. Your script works after you selected an option in the Strategic Objective field.
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.
First I've added the bahaviour vor the Initiatives field, therefore it didn't worked. After I've added it to the Strategic Objectives field it worked. Ty 4 your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.