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
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

509 views 6 8
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
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