The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
I am working on writing a groovy script for calculating Epic Rollups. I would like to know is there any way of getting the global values for the user, issue assuming there is an epic?
I want to use something like this,
USER = 'invinci' children = retrieveIssuesInEpic(issue) total = sumOfOriginalEstimates(children)
Here,
1. USER is the one with browse projects permissions
2. children represents the subtasks
3. sumOfOriginalEstimates(children) is the time taken.
How would I let the script know of the parent/child key values whenever an issue is created on the jira web application?
Thank you!
You don't invoke Script Fields. They are invoked when the issue is viewed. I use them heavily depending on the use-case.
Word to the wise: You should configure the custom field scope tightly for script fields. A script field can be a lot more expensive than say, a string text field. You should make sure the custom field context to only include projects and issue types that it's relevant for.
For example, this field would only be used by Software Development teams. You would only use this field on the Epic issue type. Your context should look something like this:
In addition to the custom field context, you should edit the custom field and change the searcher to Duration Searcher:
Your script should accomplish the following:
An example of what this script could look like is below. I'm no groovy expert. I do not know what version of JIRA you're using and I do not know how you want your data presented, so this may not work for you. This doesn't consider sub-tasks, so you'll likely want to obtain the aggregate estimate instead. I didn't have the time to complete this though: I just mostly took an existing field I had and modified it.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink import com.atlassian.jira.issue.link.IssueLinkManager import com.atlassian.jira.issue.link.IssueLinkType import com.atlassian.jira.issue.link.IssueLinkTypeManager import com.atlassian.jira.issue.issuetype.IssueType import com.atlassian.jira.config.IssueTypeManager enableCache = {-> false} IssueType getIssueTypeByName(String name){ for(IssueType issueType in ComponentAccessor.getComponent(IssueTypeManager.class).getIssueTypes()){ if(issueType.getName() == name){ return issueType } } return null } String issueTypeName = "Epic" String issueLinkTypeName = "Epic-Story Link" IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager() IssueLinkTypeManager issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager.class) IssueLinkType[] issueLinkTypes = issueLinkTypeManager.getIssueLinkTypesByName(issueLinkTypeName) IssueLink[] issueLinks = issueLinkManager.getOutwardLinks(issue.id) IssueType issueType = getIssueTypeByName(issueTypeName) if( issue && issueType && issueLinkTypes.size() > 0 && issue.getIssueType().name == issueType.getName() && issueLinks.size() > 0 ) { List<IssueLink> relevantIssueLinks = new ArrayList() for(issueLink in issueLinks){ if(issueLink.getIssueLinkType().name == issueLinkTypes.first().getName()){ relevantIssueLinks.add(issueLink) } } if(relevantIssueLinks.size() > 0){ Long originalEstimate = 0 for(issueLink in relevantIssueLinks){ Issue linkedIssue = issueLink.getDestinationObject() if(linkedIssue.getOriginalEstimate()){ originalEstimate = originalEstimate + linkedIssue.getOriginalEstimate() } }
if(originalEstimate > 0){ return originalEstimate
} } }
hey Steven,
Thanks for the detailed explanation. Now I get the idea of how to work on my script.
Thanks a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's unclear to me: Is this a listener? You want this to execute on Issue_Created/Issue_Updated?
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.
Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.