It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Cannot update Value scripted field

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)
}

 

1 answer

0 votes

Scripted fields do not contain data directly, and they cannot be "set".

A scripted field works out what data to display, search on and sort by, by using the script associated with it.

I don't think you want a post-function here at all.  You should take this script and add it to the script for the scripted field, then change the bold lines to "return <content I want to see>" instead of "setCustomField".

Hi @NI

How to get value of scripted field in script.Do you have any idea?

def dev_estimate = customFieldManager.getCustomFieldObject("customfield_12345");
log.warn("dev_estimate=="+dev_estimate);

def categoryFieldValue = issue.getCustomFieldValue(dev_estimate);
log.warn("dev_estimate value=="+categoryFieldValue);

 

Above code is not giving me value of scripted field i.e.dev_estimate is my scripted field

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

273 views 1 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you