Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,396
Community Members
 
Community Events
184
Community Groups

How to copy values from Epic to Story?

I would like to try the Behaviours add-on to copy value from a text field from epic to story. We have a script for post function but some workflows are to big and it makes the maintenance awkward.

We are using:

  • JIRA server v7.2.7
  • Adaptavist ScriptRunner for JIRA v4.3.19

our script for post function:

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.managers.DefaultIssueManager;
import com.atlassian.jira.issue.IssueManager;
CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager()
CustomField el = cfm.getCustomFieldObject('customfield_11571')
CustomField cpi = cfm.getCustomFieldObject('customfield_11095')
IssueManager im = ComponentAccessor.getIssueManager()
issue.setCustomFieldValue(cpi, im.getIssueByCurrentKey((String)issue.getCustomFieldValue(el)).getCustomFieldValue(cpi))

 I tried to use the script from CGM, but I get an error message:

https://community.atlassian.com/t5/Jira-questions/Copy-values-from-Epic-to-Story-on-creation/qaq-p/214566#U710980

Can you help me?

Best regards,
Tatiana

1 answer

1 vote
Neta Elyakim
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 25, 2018

Hey,

In order to copy value for epic to all the story under it-(post function)

Try this:

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

MutableIssue issue = issue
if (issue.getIssueType().name == "Epic"){
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
List<IssueLink> outwardLinks = issueLinkManager.getOutwardLinks(issue.getId())
CustomField cf1 = customFieldManager.getCustomFieldObjectByName("cutsomfieldname")
def cfvalue = issue.getCustomFieldValue(cf1)

List<Issue> issueinepic = new ArrayList<Issue>();

for(int i=0;i<outwardLinks.size();i++){
if(outwardLinks[i].getIssueLinkType().getName()=="Epic-Story Link"){
def destObject = outwardLinks[i].getDestinationObject()
def changeHolder = new DefaultIssueChangeHolder();
cf1.updateValue(null, destObject, new ModifiedValue(destObject.getCustomFieldValue(cf1),cfvalue), changeHolder);
issue.store()

}
}
}

Thank you for the prompt response.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events