I'll admit I'm not very good at this and have been struggling for days. I've actually reached the end of the information highway and resorted to going 3 pages deep in Google. I'm trying to use ScriptRunner (Listeners) during a issue creation to match description field with Regex (which works) and then insert into a Custom Field. I feel like I'm close, but I'm now having issues with data conversion:
java.util.regex.Matcher cannot be cast to java.lang.Double
I'm guessing it's barking about the Description field which I did getClass:
description: class java.lang.String
I know the Custom Field is a Number Field, since I created it. Here's what I've written, please don't beat up on my:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import java.util.regex.Matcher
import java.util.regex.Pattern
log.error("LogStart")
def issueManager = ComponentAccessor.getIssueManager()
log.error("Key: " + event.issue.getKey())
log.error("LogEnd")
def currentIssue = issueManager.getIssueObject(event.issue.getKey())
log.error("issue: " + currentIssue)
log.error("description: " + currentIssue.description)
log.error("description: " + currentIssue.description.getClass())
Matcher RegExResult = (currentIssue.description =~ /Member Number:.*?} ([1-9][0-9]{4,22})/)
def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Foo Number"}
def changeHolder = new DefaultIssueChangeHolder()
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), RegExResult),changeHolder)
I'd appreciate any help or input, this has been very frustrating - Thanks in advance!