Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Inherit fields from epic to epic-linked user story

Deleted user Sep 04, 2017

Hi,
is it possible to inherit fields from Epic Story to all epic-linked issues.
For example I want to inherit the field "Affects Version/s" which is a standard jira field from an epic to all it's epic-linked user storys.

I also want to inherit custom field values.

Does anybody offer a solution about this?
Is it possible to cover this with Script Runner?

Thanks,
Michael

3 answers

2 votes
Deleted user Oct 22, 2017

Allright, I got it. Here is my solution:

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItemImpl
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.util.ImportUtils


CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueManager = ComponentAccessor.getIssueManager()

// Check if Issue Type is Story
if (issue.getIssueType().getName() == "Story" ) {

// Get Custom Field as string (Epic Link)
def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")

// Get Custom Field Value as String
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
String EpicName = issue.getCustomFieldValue(epicLink);

if(EpicName){
// Get Epic from Issue
def epicIssue = issue.getCustomFieldValue(epicLinkCf) as Issue

// Get Fix Version from Epic
def currentValue = epicIssue.getFixVersions()

// Set Fix Version to Story
issue.setFixVersions(currentValue);
}
}

Hello Michael,

Could you please modify above script further for below Scenario:

Create a user story, update a Epic Link ==> Fix Version should be copied from Epic to User Story.

I want to use this with Script Listener, Issue updated Event.

It would be helpful for me and community users.

Thanks in advance.

Suresh

Hi Suresh,

yes that would be nice, I would like to have this feature too :)

Does anyone can offer a solution for this?

 

Thanks,

Michael

Yes, I think the appropriate solution is to use Script Runner's post function.

  • you will add postfunction to initial transition on workflows which handle issues created "for epic". Postfunction is called Script Post-Function
  • then you will implement a script which will:
    • check whether epic is connected to the created issue, you can check project or issue type of the issue too (you might need to copy values between fields only for few projects and issue types)
    • get the Epic issue (Epic Link custom field)
    • copy the value of epic issue's field to the new issue

You will have to play with it little bit to find out what is the type of value returned for Epic Link custom field etc, but it should work.

Deleted user Oct 02, 2017

Hi thanks for your answer.

Can you help furthermore me with this script? I started but got stuck because I don't know how to copy a field from the linked epic to set it to the user story...

So far I got this:

I got the Epic Issue "Epic", but how can I get the field "Fix Versions" to set it to the User Story?

Thanks again for answering!

Michael

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueManager = ComponentAccessor.getIssueManager()

// Check if Issue Type is Story
if (issue.getIssueType().getName() == "Story" ) {

// Get Custom Field (Epic Link)
CustomField epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');

// Get Content of Custom Field (Epic Name)
String EpicName = issue.getCustomFieldValue(epicLink);

// Get the Epic by name
Issue Epic = issueManager.getIssueObject(EpicName);

// get content of the epic (field Fix Versions)

// Set Field (Fix Versions) from Epic Story to User Story


}

Is there a means to do the exact opposite? Take all of the child Stories and their Fix Version values and "roll-up" these and set the value of the Epic's Fix Version field?

If the children have a fix version value of:

Issue 1: AA

Issue 2: CC

Issue 3: DD, FF

Then the parent Epic would have a fix version of:

AA, CC, DD, FF

This is basically the "roll-up" function of Portfolio. However, roll-up does not actually write the field (which is unfortunate). I want the stories to be tied to releases and this to drive what Epics show for Fix Version as Epics can and do span releases in my universe.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you