You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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:
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:
Can you help me?
Best regards,
Tatiana
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()
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.