Get customField Value from Epic to be inherited by New Issue type

Using Script Runner...


I cannot get a customField value from an Epic to be inherited when I Create a new issue type that is linked to that Epic.

What I tried:

  1. I tried using the Post Function "Set Field Value from Parent" but technically the EPIC is not the parent...and, no dice.
  2. I then looked for a script to post using the "Conditional execution:" option in that same Post Function. I found a few script options to try, but I am running into issues with the variable values. The below script looks good, but any help will appreciated.

Values I know:

  • The custom Field ID is the same on the EPIC and the New Issue
    • customFieldId=11200
  • For Reference, the Custom Field Name is "Activity Type" or the above custom id (11200). This is one of my hangups because I am not sure how to define this. Do I call it "ActivityType", "11200", etc

Code I found on this board and tried to manipulate:

Tried being the operative word. smile


import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

if (issue.getIssueTypeObject().getName() == "Story" ) {
    CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
    Issue epic = issue.getCustomFieldValue(epicLink);

Please help. Will be much appreciated! heart

1 answer

Getting these errors with Script Runner:


avax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script10.groovy: 8: unable to resolve class CustomFieldManager 
 @ line 8, column 20.
   CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

Script10.groovy: 11: unable to resolve class CustomField 
 @ line 11, column 17.
       CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');

Script10.groovy: 12: unable to resolve class Issue 
 @ line 12, column 11.
       Issue epic = issue.getCustomFieldValue(epicLink);

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,329 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot