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
Joshua Yamdogo Community Champion Nov 14, 2017

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,825 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot