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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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

Edited

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.
Aug 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