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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

54 views 1 0
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