Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jee Christiansen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 23, 2014

Using Script Runner...


Problem: 

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);
    if(epic)
    {
        issue.setActivityType(epic.getActivityType());    
    }
}


Please help. Will be much appreciated! heart

2 answers

0 votes
Jee Christiansen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 24, 2014

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