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

Set custom field value [Script Runner] (ComponentManager has been deprecated)

I'm trying to create and populate custom fields and options. The example code I found uses the ComponentManager:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = customFieldManager.getCustomFieldObjectByName("testgroovy2")
def userCf = customFieldManager.getCustomFieldObjectByName("user picker")

issue.setCustomFieldValue(cf,"Its Works")
issue.setCustomFieldValue(userCf, user)
issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

ComponentManager has been deprecated since JIRA 7.11.

I can not find any example code that works in the Script Console.

Can any one out there give me a hand, or point in the right direction.


1 answer

this is a good example, but if you want to use it in console, you need to define issue object before you try to use it:

def issue = issueManager.getIssueObject("JIRA-123")

otherwise it looks like either postfunction or listener piece of code

Suggest an answer

Log in or Sign up to answer

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