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
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

25,239 views 2 7
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