Hello Community,
I´ve found an script to calculate the sum of Story Points in all linked Issues with a scripted field via ScriptRunner and adjusted it to my use case like this:
Now the requirement has changed, and I would like to have the sum of Story Points in all linked issues except the issueLinkType "is blocked by". In case that I´m not a developer and new to jira, I have no clue how to modify this script, to run it for my use case. I hope that someone has an idea. Thank you in advance for your support.
For your requirement, you should try something like this:-
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.issueLinkManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def storyPoints = customFieldManager.getCustomFieldObjectsByName('Story Points').first()
issue.getCustomFieldValue(storyPoints) as Double
def linkCollection = issueLinkManager.getLinkCollection(issue, loggedInUser) // to get all the linked issues for the current issue
def excludedIssues = linkCollection.getInwardIssues('Blocks')
def totalStoryPoints = linkCollection.allIssues - excludedIssues // to filter out issues that are blocked
totalStoryPoints.collect {
it.getCustomFieldValue(storyPoints) as Double
}.sum()
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Scripted Field's configuration:-
I also include a couple of test screenshots for your reference:-
The first issue is linked to 3 other issues. Two are using the relates to link, and one is using the is blocked by link. If you compare the first screenshot below with the other three screenshots, you will notice that in the issue MOCK-1, only the story points from MOCK-2 and MOCK-3 are calculated. However, the story points from MOCK-4 are excluded because it is a blocker.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
Does the solution I provided answer your question?
If yes, could you please accept the solution?
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_
first of all thank you very much for the detailed answer. I have to apologize, that I didn´t answered yet. I was very busy this week due to other subjects in my company. In case of that I couldn´t test ist yet. I will response and accept your solution until Monady evening.
I hope that this is okay for you.
Thank you and kind regards.
Shahin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_
Hi
I also want to calculate custom field like
condition 1 : linked id = 10309, 10703
condition 2 : issue type id = 10511, 10612, 10603
condition 3 : linked issue status = completion
calcuate and update custom field ("ENM_Planpercent") : (number of condition1 & condition2 & condition3) / (total number of condition1) x 100
Can you help me?
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.
@Ram hi,
I have one issuetype as feature and i need to created on scripted filed for check and how many linked feature card count on epic level can you solve this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @jun lee
In your previous comment, you mentioned:-
I also want to calculate custom field like
condition 1 : linked id = 10309, 10703
condition 2 : issue type id = 10511, 10612, 10603
condition 3 : linked issue status = completion
calcuate and update custom field ("ENM_Planpercent") : (number of condition1 & condition2 & condition3) / (total number of condition1) x 100
Could you please specify what link types 10309 and 10703 refer to?
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your previous comment, you mentioned:-
I have one issuetype as feature and i need to created on scripted filed for check and how many linked feature card count on epic level can you solve this.
If you expect to get the could from the Initiative to the Epic via child link. This is not directly doable.
You would first have to create a custom link, for example, Parent / Child, and link your Feature with the Epic issue accordingly. Only once this is done will you be able to get a count for the Features and Epics.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ Hi Can you help on need to make one scrip field to calculate total count of Feature an epic link .
*note - not require for issue link count
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_
thank you again for the effort. After some tries, I´ve figured out the right modification for our instance. Now it´s working pretty well.
best regards
Shahin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey RamKumar,
My requirement is bit similar to this but tried myself couldn't achieve it. I want to get the sum of Story points under epic.
Currently Stories are linked to epic using epic link. I have to calculate all the stories story points that are linked epic using epiclink and sum their story points and display.
Will that be possible?
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.