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

2 answers

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
Published Mar 14, 2019 in Jira

Updates to give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

635 views 1 15
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