The error I am receiving is 'Cannot cast object with class 'com.atlassian.jira.customfields.option.LazyLoadedOption' to class 'java.util.Map'.
I've tried a couple of ways resulting in the same error, but here is the code I am currently working with:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira. issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.option.*
def issue = issue as MutableIssue
def issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def changeHolder = new DefaultIssueChangeHolder()
def user = ComponentAccessor.getUserManager().getUserByName("admin")
def optionsManager = ComponentAccessor.getOptionsManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find{it.name == "Authorization processed result"}
Option breachedOption = ComponentAccessor.optionsManager.findByOptionId(199944)
Option notBreachedOption = ComponentAccessor.optionsManager.findByOptionId(199945)
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), notBreachedOption), changeHolder)
Hello
Check this article https://community.atlassian.com/t5/Jira-questions/How-set-custom-field-value-in-Issue-Create-event/qaq-p/1216402#M388386
You need setCustomFieldValue method together with updateIssue
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.