Very useful example to get the values of a cascading customfield using Groovy in Jira.

import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType
import org.apache.log4j.Category

def field = customFieldMananger.getCustomFieldObjectByName("CASCADING_CUSTOMFIELD_NAME")
Object cfVal = issue.getCustomFieldValue(field)

HashMap<String, Option> hashMapEntries = (HashMap<String, Option>) cfVal
if (hashMapEntries != null) {
Option parent = hashMapEntries.get(CascadingSelectCFType.PARENT_KEY)
Option child = hashMapEntries.get(CascadingSelectCFType.CHILD_KEY)
first = parent.toString()
second = child.toString()
log.debug("Cascading values selected: $first - $second")

Posted by:.

2 replies on “Jira Groovy example to get values from a CASCADING custom field

    def cfModule = customFieldManager.getCustomFieldObjects(sourceIssue).find { == "Module"}"Module customField: " + cfModule)
    def cFieldValue = sourceIssue.getCustomFieldValue(cfModule)
    log.warn("Show cFieldValue " + cFieldValue)
    def parentValue = cFieldValue[null]
    def childValue = cFieldValue["1"]
    log.warn("Show cFieldValue parentValue " + parentValue)
    log.warn("Show cFieldValue childValue " + childValue)

    Liked by 2 people

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s