Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Error white scriptrunner about components field

BYA December 23, 2020

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
Nic Brough -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.
December 23, 2020

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()

BYA December 24, 2020

Hello, 

Is workinf, thank you so much.

!!!!!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events