Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,245
Community Members
 
Community Events
165
Community Groups

Error white scriptrunner about components field

Hello,

I want to retrieve the value of the components field :


import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()

def issueKey = "RP-83"
def issue = issueManager.getIssueObject(issueKey)

def productCf = customFieldManager.getCustomFieldObjectByName("components")

def productValue = issue.getCustomFieldValue(productCf)

when i run this script, i have this error : 

2020-12-23 14:12:57,537 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2020-12-23 14:12:57,537 ERROR [common.UserScriptEndpoint]: Script console script failed: java.lang.NullPointerException at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:951) at com.atlassian.jira.issue.Issue$getCustomFieldValue$3.call(Unknown Source) at Script669.run(Script669.groovy:11)

can you please help me ? 

Thanks,

BR

Fayçal

1 answer

1 accepted

0 votes
Answer accepted

Components is not a custom field (unless you've added one with that name)!

Instead of trying to find its id from its name and reading a custom field, try simply

issue.getComponents()

Hello, 

Is workinf, thank you so much.

!!!!!!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

329 views 0 7
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