I am creating a listener that is triggered by a new link being created. The listener is then attempting to create a new Issue which has a Cascading Select List field which should be populated. However this field is not being populated - despite the Listener executing without error.
Here is my code (trimmed to show only the issue creation):
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cfm = ComponentAccessor.customFieldManager
IssueManager issueManager = ComponentAccessor.getIssueManager()
def optionsManger = ComponentAccessor.getOptionsManager()
Issue original_test = issueManager.getIssueObject('ABC-1')
Issue new_test= ComponentAccessor.getIssueFactory().getIssue()
def getParentChildOptionsByValue(CustomField customField, Issue issue, String parentValue, String childValue) {
def availableOptions = ComponentAccessor.optionsManager.getOptions(customField.getRelevantConfig(issue))
def rootOptions = availableOptions.getRootOptions()
def parentOptionToSet = availableOptions.find { it.value == parentValue }
def childOptions = rootOptions[0].getChildOptions()
def childOptionToSet = childOptions.find { it.value == childValue }
return [null: parentOptionToSet, "1": childOptionToSet]
}
new_test.setProjectId(original_test.getProjectObject().getId())
new_test.setIssueTypeId(original_test.issueType.getId())
new_test.setSummary("Revised Test")
new_test.setReporterId(original_test.reporterId)
new_test.setAssigneeId(original_test.assigneeId)
new_test.setDescription(original_test.getDescription())
new_test.setCustomFieldValue(
cfm.getCustomFieldObject(10450),
getParentChildOptionsByValue(
cfm.getCustomFieldObject(10450),
original_test,
"Specification Based",
"Equivalence Partitioning"
)
) // Cascading select
log.debug("Cascading Select List before creation:\t"+new_test.getCustomFieldValue(10450).toString())
new_test = issueManager.createIssueObject(user, new_test)
log.debug(new_test.key)
log.debug("Cascading Select List after creation:\t"+new_test.getCustomFieldValue(10450).toString())
And here is the log:
2025-04-11T14:16:15,037 DEBUG [runner.ScriptBindingsManager]: Cascading Select List before creation: [null:Specification Based, 1:Equivalence Partitioning]
2025-04-11T14:16:15,204 DEBUG [runner.ScriptBindingsManager]: No selected values found, terminating script execution.
2025-04-11T14:16:15,887 DEBUG [runner.ScriptBindingsManager]: PETM-40
2025-04-11T14:16:15,887 DEBUG [runner.ScriptBindingsManager]: Cascading Select List after creation: null
I am confused most by the 2nd line of the log. It is not output directly by my code but I am assuming it is due to the createIssueObject method failing to write the Cascading Select List but creating the issue regardless.
Can anyone help me understand why this is failing and what I can do to resolve this?