Hi together,
in our Jira-Project we have a custom field of type "asset object". This custom field allows multiple value selection.
I wrote a groovy script, which set a new value and then update the custom field. The specific part of my code is shown below:
//Define the specific customfield of Task
def cfID_12500 = "customfield_12500"
//Get the customfield object
def cfObject_12500 = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(cfID_12500)
// Get the custom field value for the specific issue
def cfValue_12500 = issue_parent.getCustomFieldValue(cfObject_12500)
//The list contain duplicate values (e.g. ABC, XYZ, ABC, HIZ)
//First remove all duplicates by converting it to a Set and then back to List
def uniqueSet_of_OEs = listOEs_of_Tasks as Set
def uniqueListOEs_of_Tasks = uniqueSet_of_OEs.toList()
//Set new values for the asset object field
def cfnewValue_12500 = uniqueListOEs_of_Tasks
issue.setCustomFieldValue(cfObject_12500, cfnewValue_12500)
//Update the issue
ComponentAccessor.issueManager.updateIssue(ComponentAccessor.jiraAuthenticationContext.getLoggedInUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Somehow my code is not working. When I execute it, it throw an error in the last line.
Error
2024-01-04 08:42:38,891 ERROR [common.UserScriptEndpoint]: Script console script failed:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.riadalabs.jira.plugins.insight.services.model.ObjectBean
I understand the error, but I don't know how to solve it.
Can I use the "update issue" only for variables with a single value?
Would be great to get some help
Best Regards Dominik