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

Using ComponentAccessor () in Script Runner in Jira Cloud

Mayur Gaikwad_Tech PMO
Contributor
February 8, 2024

How to use ComponentAccessor () in Script Runner in Jira Cloud.

I'm trying to get customfield value through this method

2 answers

2 votes
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.
February 8, 2024

Hi Mayur,

Cloud and DC are very different pieces of software, and although Scriptrunner for Jira only has one name, it is also two very different things.

DC code will generally not work on Cloud, the language and structures are very different.

You don't need to use componentAccessor on Cloud (you generally don't need it on DC any more, if you've got a version of Scriptrunner that enables HAPI).

Have a look at https://library.adaptavist.com/entity/update-cf-values-all-issues-cloud?tab=cloud - it shows you how to read and write custom fields with Cloud scripts

0 votes
Uday Kiran Bhaviri
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.
February 8, 2024

import com.atlassian.jira.issue.CustomFieldManager;

import com.atlassian.jira.issue.fields.CustomField;

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def cField = customFieldManager.getCustomFieldObject("customfield_10301")

// You can also use by name

//Def cField = customFieldManager.getCustomFieldObjectsByName("customfieldname")[0]

def cFieldValue = issue.getCustomFieldValue(cField)

Hope this will be helpful.

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.
February 8, 2024

It is not, the question is for Cloud, not DC

Like Mayur Gaikwad_Tech PMO likes this
Uday Kiran Bhaviri
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.
February 9, 2024

Ohhh Thanks @Nic Brough -Adaptavist- 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events