Script Runner - Scripted field display parent issue custom field on sub-task

Hello,

I have been trying to create a scripted field on a sub-task. This scripted field will display data from the parent issue. This field is a numeric value custom field

Parent Issue - Improvment

Custom Field - DBA Estimate (Numeric)

Sub-Task

Scripted field - Parent DBA Estimate

The script I've created isn't working correctly -

import com.atlassian.jira.issue.Issue;

import com.atlassian.jira.ComponentManager;

import com.atlassian.jira.issue.CustomFieldManager;

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

def abc123 = issue.parentObject.getCustomFieldValue("DBA Estimate");

return abc123;

How do I get the Scripted field to display the numeric value from the parent issue?
Thanks in advance.
Andre

1 answer

1 accepted

Here's the correct code:

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("DBA Estimate")
def abc123 = issue.parentObject.getCustomFieldValue(field);

return abc123;

Also make sure to set template : Number Field on the scripted field and also set the searcher to Number Searcher

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

346 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you