Hi,
We need to copy a value from custom field to our text scripted field.
Below is the script that we create, which works properly as post function in workflow, however, has an error in scripted fields of the Script Runner in JIRA.
the error: "Cannot find matching method" on the bold rows.
Someone know why? and how to fix it?
import org.apache.log4j.Logger
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.jira.event.type.EventDispatchOption
def Category log = Category.getInstance("com.onresolve.jira.groovy.Condition")
log.setLevel(org.apache.log4j.Level.DEBUG)
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def newPVP = customFieldManager.getCustomFieldObject('customfield_16680') //PVP - custom field
def newPVPValue = issue.getCustomFieldValue(newPVP) as String
log.info("newPVPValue: " + newPVPValue)
def PVPCommit = customFieldManager.getCustomFieldObject('customfield_16781') //PVP Committed - custom field
def PVPCommitValue = issue.getCustomFieldValue(PVPCommit) as String
log.info("PVPCommitValue: " + PVPCommitValue)
if (PVPCommitValue==null) {
issue.setCustomFieldValue(PVPCommit, newPVPValue)
// issue.updateValue(PVPCommit, newPVPValue)
} else {
issue.setCustomFieldValue(PVPCommit, PVPCommitValue + ", " + newPVPValue)
}
Community moderators have prevented the ability to post new answers.
Hi Mariana,
We have example scripts on our new website that detail how to set custom field values. Take a look here: https://library.adaptavist.com/entity/update-the-value-of-a-custom-field-in-jira
Have you actually tried running the script? The static type checker may tell you there's an error, but it'll probably work anyway.
Thanks,
Josh
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.