Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update screen onaction - Behaviours Option List

Celik Vedat April 19, 2018

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

1 answer

1 accepted

1 vote
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2018

ScriptRunner works only after you selected an option in the list, not in the process. I guess, you can not change it.

Celik Vedat April 19, 2018

Isn't it, at least, possible to change the values after I've selected an option instead of clicking in the field?

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2018

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.

Celik Vedat April 19, 2018

Ty, I'll try this

Celik Vedat April 23, 2018

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!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events