Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Listener: Copy Organizations to a custom field

Clemens Kahrer November 4, 2020

Hey!

I would like to copy the value of the Field "Organizations" to a custom field "customer organization" whenever the field "Organizations" is changed. I came as far as the following code:

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

def customFieldManager = ComponentAccessor.CustomFieldManager
def issue = event.issue

def tgtField = customFieldManager.getCustomFieldObjects(issue).findByName("customer organization")
def calcField = customFieldManager.getCustomFieldObjects(issue).findByName("Organizations")

def newValue = issue.getCustomFieldValue(calcField)

tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), newValue), new DefaultIssueChangeHolder())

Executing the listener always fails. This is what the logs say:

2020-11-04 15:52:30,517 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2020-11-04 15:52:30,517 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.servicedesk.internal.feature.organization.event.OrganisationsAddedToIssueEventImpl, file: null
groovy.lang.MissingPropertyException: No such property: CustomFieldManager for class: com.atlassian.jira.component.ComponentAccessor
Possible solutions: customFieldManager
	at Script76.run(Script76.groovy:5)

Anybody knows a solution for this problem?

best regards,
Clemens

 

1 answer

0 votes
Jeroen Poismans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 18, 2020

Hi,

First try changing the declaration of the CustomfieldManager to this:

def customFieldManager = ComponentAccessor.getCustomFieldManager()

Let me know if this (partially) fixes your problem.

 

Regards,

Jeroen

Clemens Kahrer April 1, 2021

at least I get no error anymore

I just tried and executed the event the listener should respond to (added an organization to an issue), but it didn't run

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.0
TAGS
AUG Leaders

Atlassian Community Events