Hi,
I am using Jira Software version 8.6 with Scriprunner.
Trying to write a listener that reads a single select list custom field and copies it to a number custom field of an issue.
I am getting the following error:
Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '13' with class 'com.atlassian.jira.issue.customfields.option.LazyLoadedOption' to class 'java.lang.Double'
I am using the following code:
"New Story Points" - Single Select list
"Story Points" - Number field
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
def newStoryPointsChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "New Story Points"}
if (newStoryPointsChanged){
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def targetField = customFieldManager.getCustomFieldObjectByName("Story Points")
def sourceField = customFieldManager.getCustomFieldObjectByName("New Story Points")
def sourceFieldValue = (Double) event.issue.getCustomFieldValue(sourceField)
def targetFieldValue = event.issue.getCustomFieldValue(targetField)
targetField.updateValue(null, event.issue, new ModifiedValue(targetFieldValue, sourceFieldValue),new DefaultIssueChangeHolder())
}
Can you suggest the correct way for the following line:
targetField.updateValue(null, event.issue, new ModifiedValue(targetFieldValue, sourceFieldValue),new DefaultIssueChangeHolder())
Thanks,
Rupa