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

Sergio Palacio October 16, 2017

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 @ 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.
November 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 Sign up to answer