Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
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

Create a calculated custom field in an epic that sums the value of a custom field of linked issues? Edited

Hi Everyone, 

We have the Addon JIRA MISC CUSTOM FIELD 

https://innovalog.atlassian.net/wiki/spaces/JMCF/overview?homepageId=141891457

I would like to create a calculated field in an epic that would sum the values of a number custom field filtered on the current linked issues of the epic. 

I am pretty sure this is possible to do it with the addon but i am struggling to write the right script, as I have too few knowledge on Groovy script. Could anyone help me with a code ? 

 

Here is what i would like : 

Epic

Calculated custom field = Sum of values of linked issues Custom field 1

Epic Linked issues

Issue 1

Value Custom field 1

Issue 2

Value Custom field 1

Issue 3

Value Custom field 1

 

Thank you so much for your help! 

1 answer

0 votes

Hi,

what is the link between the Epic and the issues from which to sum the custom field? Are they the issues that belong to the Epic? If so, you can use this:

issue.stories.sum {it.get("customfield_12345")?:0}

If they are issues linked to the Epic through issue links, you can do something like:

issue.getLinkedIssues("link type direction").sum {it.get("customfield_12345")?:0}

Hi David, Thanks for your answer! 

I tried and the script returns no error but even though my fields have values it still returns "null"

I created 3 tasks and completed values in the custom number field i want to sum + have added the epic link but it doesn't seem to sum the value in the calculated field in the epic...

Could it be because of the "link type direction"? 

 

Thanks again for your precious help! 

 

image.png

If you have added the Epic Link on the tasks, that means the task belong to the Epic. You therefore need to use the first script I provided. 

HI, 

Please provide script to add sum of one or more custom fields from Stories to EPic. 

 

Here is what i would like : 

Epic

Calculated custom field = Sum of values of linked issues Custom field 1 and Custom field 2

Epic Linked issues

Issue 1

Value Custom field 1

Value Custom field 2

Issue 2 

Value Custom field 1

Value Custom field 2

 

Thanks,

Gunti

Hi @Gunti_Reddy ,

try this:

issue.stories.sum {
it.get("custom field 1")?:0 + it.get("custom field 2")?:0
}

Hi David, Thanks for your response, 

 

getting below error, but it works when i add one custom field for sum.

 

Message:
groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.Integer#plus.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
 [class java.lang.Character]
 [class java.lang.String]
 [class java.lang.Number]


 Below line works for one custom field sum.

issue.stories.sum {it.get("customfield_15462")?:0} 

 

Thanks,

Gunti

I made small changes and working for two custom fields sum  as well.

 

issue.stories.sum {it.get("customfield_15460")?:0} + issue.stories.sum {it.get("customfield_15462")?:0}

Yes, sorry, I had forgotten to add parentheses:

issue.stories.sum {
(it.get("custom field 1")?:0) + (it.get("custom field 2")?:0)
}

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