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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Listener: Copy Organizations to a custom field

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

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.0
TAGS
Community showcase
Published in Jira Service Management

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

163 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you