Listener Update to JIRA 7 to Copy CustomField from Subtask to Parent to Subtasks

Hi I have a code to set the parent custom field from the same customfield in the sibtask.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.jira.issue.fields.CustomField

def parentIssue = issue.getParentObject()

 

def cfield = customFieldManager.getCustomFieldObject("customfield_10228")
def cfield_parent = customFieldManager.getCustomFieldObject("customfield_10228")
def val_cfield = issue.getCustomFieldValue(cfield)

parentIssue.setCustomFieldValue(cfield, issue.getCustomFieldValue(val_cfield))

 

But I'm having an error.  "Cannot find matching method line 16"

Do you know about this error. the imported class are not correct?

thanks in advance.

1 answer

Hi Sergio,

You seem to be missing a definition for customFieldManager.

Also, I am not sure where you are using this script, but you might need to use the updateValue() method.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def parentIssue = issue.getParentObject()

def cfield = customFieldManager.getCustomFieldObject("customfield_10228")
def val_cfield = issue.getCustomFieldValue(cfield)

cfield.updateValue(null, parentIssue, new ModifiedValue(parentIssue.getCustomFieldValue(cfield), val_cfield),new DefaultIssueChangeHolder()) 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

491 views 2 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you