ScriptRunner Behaviour: Get the value for a custom Field Parent Link on create and edit

Michael Reinhold
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2023

Good day,

For a ScriptRunner Behaviour on a field change, I try to extract the values of a custom field Parent Link (key: com.atlassian.jpo:jpo-custom-field-parent).

I want to check if a value is already set in the create screen and if the issue is linked to a parent on the edit screen or if the field has a value in the edit screen itself.

 

So far I try to access the field like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField

def customFieldId = "customfield_14701"
def customField = ComponentAccessor.customFieldManager.getCustomFieldObject(customFieldId)

log.error('key: ' + customField.getCustomFieldType().getKey()) -> return com.atlassian.jpo:jpo-custom-field-parent
Thank you!

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Hauke Bruno Wollentin
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.
August 15, 2023

I'm not sure if I understand the question correctly, but to get the value of that Custom Field you simply could use the Issue objects "getCustomFieldValue()" method (see https://docs.atlassian.com/software/jira/docs/api/9.10.0/com/atlassian/jira/issue/Issue.html#getCustomFieldValue-com.atlassian.jira.issue.fields.CustomField- )

issue is the binding variable in Behaviours, it can be used like

def customFieldId = "customfield_14701"
def customField = ComponentAccessor.customFieldManager.getCustomFieldObject(customFieldId)

def customFieldValue = issue.getCustomFieldValue(customField)
TAGS
AUG Leaders

Atlassian Community Events