How to use ComponentAccessor () in Script Runner in Jira Cloud.
I'm trying to get customfield value through this method
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.
It is not, the question is for Cloud, not DC
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
Ohhh Thanks @Nic Brough -Adaptavist-
It looks like you're new here. Sign in or register to get started.