Hello,
I am trying to update select field(responsibleSquad) value based on the value selected in cascading first value ("UC Services")
I found no error. But it is not working as expected. Am I missing something?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
def responsibleSquad = getFieldById("customfield_13605")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldB = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Responsible Squad")
def fieldConfigB = customFieldB.getRelevantConfig(getIssueContext())
def optionsB = optionsManager.getOptions(fieldConfigB)
def optionBI = optionsB.find {it.value == "Experience Development Squad"}
def optionBII = optionsB.find {it.value == "Adobe Platform"}
def optionBIII = optionsB.find {it.value == "Analytics & Insight"}
Object value = getCustomFieldValue("UC Services")
CustomFieldParams params = (CustomFieldParams) value
if (params != null) {
Object parent = params.getFirstValueForNullKey()
Object child = params.getFirstValueForKey("1")
if (parent.toString() == "Web Personalisation - Brand") {
responsibleSquad.setFormValue(optionBI.optionId)
}
else if (parent.toString() == "Lifecycle Comms") {
responsibleSquad.setFormValue(optionBII.optionId)
}
else if (parent.toString() == "Event-Based Trigger Comms") {
responsibleSquad.setFormValue(optionBIII.optionId)
}
}
Are you doing this in a behaviour?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is an example of setting the value of a single select list based on the parent value of a cascading select list in a behaviour:
import com.atlassian.jira.component.ComponentAccessor
def optionsManager = ComponentAccessor.optionsManager
def customFieldManager = ComponentAccessor.customFieldManager
def cascadeListName = "cascade_list_name"
def cascadeList = getFieldByName(cascadeListName)
def parentValue = cascadeList.value[0]
def childValue = cascadeList.value[1]
def selectListName = "select_list_name"
def selectList = getFieldByName(selectListName)
def selectListCF = customFieldManager.getCustomFieldObjectsByName(selectListName)[0]
def selectListFieldConfig = selectListCF.getRelevantConfig(issueContext)
def options = optionsManager.getOptions(selectListFieldConfig)
def optionToSet = options.find {it.value == "option_name"}
if (parentValue == "something") {
selectList.setFormValue(optionToSet.optionId)
}
You can follow the outline of this code and modify it to suit your needs.
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.
Youre welcome!
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.