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

0 votes

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
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

137 views 0 6
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