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

Accepted Answer
3 votes

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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,072 views 2 7
Join discussion

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