Script Runner - error in Setting Cascading Select values - error using code example Edited

Untitled.png

When i am trying to update cascade field "Category" using your example i get errors adn it doesnt work

 

def optionsManager = ComponentAccessor.getOptionsManager() def c

ustomFieldManager = ComponentAccessor.getCustomFieldManager() def fieldName = "Category" def field = getFieldByName(fieldName) def customField = customFieldManager.getCustomFieldObjectByName(fieldName) def fieldConfig = customField.getRelevantConfig(getIssueContext()) def options = optionsManager.getOptions(fieldConfig) def parentOption = options.find {it.value == "A"} def childOption = parentOption?.childOptions?.find {it.value == "A1"} field.setFormValue([parentOption.optionId, childOption.optionId])

1 answer

0 votes

Hi hreich.

Could you kindly state what is the error or errors that you are getting/

Cheers

Dyelamos

I am missing importers but aince i am noob i dont know which ones

You are only missing one:

import com.atlassian.jira.component.ComponentAccessor

def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fieldName = "Category"
def field = getFieldByName(fieldName)
def customField = customFieldManager.getCustomFieldObjectByName(fieldName)
def fieldConfig = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(fieldConfig)
def parentOption = options.find {it.value == "A"}
def childOption = parentOption?.childOptions?.find {it.value == "A1"}
field.setFormValue([parentOption.optionId, childOption.optionId])

 This should work.

Cheers!

Dyelamos

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

330 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you