Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,440
Community Members
 
Community Events
184
Community Groups

How to set field value?

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Joshua Yamdogo _ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Oct 24, 2018

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

TAGS
AUG Leaders

Atlassian Community Events