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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted Tuesday 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...

172 views 1 3
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