Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.
×I am looking to populate a scripted field with the number of stories resolved vs. the total number of stories so I can show on a Kanban Card (see image).
The code I have works but I am only able to count all resolved issues vs. total issues linked.
I want the calculation to be limited to Stories only.
In the pasted code, I have a commented out block that will count only linked Stories which I know works fine.
What I am missing is the code that will only count the number of resolved Stories so I can feed that value into the variable "y".
Appreciate any guidance!
import com.atlassian.jira.component.ComponentAccessor int x = 0 int y = 0 def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def linkedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, currentUser).getAllIssues() def resolvedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, issue.reporter).getAllIssues() /* if (linkedIssues.size() > 0){ for (int i = 0; i < linkedIssues.size(); i++){ // Use the following IF statements to limit the count to certain issue types if (linkedIssues[i].getIssueType().getName() == "Story"){ x = x + 1 } //if (linkedIssues[i].getIssueType().getName() == "Task"){ x = x + 1 } } } */ // Gets count of linked issues regardless of issue type x = linkedIssues.size() //Counts number of resolved issues y = resolvedIssues.count{it.resolution != null} // Formats output if (x > 0) { if (y > 0) { return "[" + y + " of " + x + "]" }}else return null
Additional question:
In lines 6 & 7, is it okay to use currentUser and issue.reporter or will this limit the calculation based on access rights?
Did you manage to solve the problem?
If you still looking for a solution you can try the following code to see if matche with your need.
import com.atlassian.jira.component.ComponentAccessor
int x = 0
int y = 0
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, currentUser).getAllIssues()
// Gets count of linked issues regardless of issue type
x = linkedIssues.size()
// Counts number of resolved stories
y = linkedIssues.count {
it.getIssueType().getName() == "Story" && it.resolution != null
}
// Formats output
if (x > 0) {
if (y > 0) {
return "[" + y + " of " + x + "]"
}
} else {
return null
}
Let me know it this helps you.
Best Regards
Please clarify are you trying to populate the completed Story points in an Epic? If yes, is the Story point total only to be updated in the Epic when the child issues transition to Done?
I do have some examples for this but I need your clarification to confirm which approach you are trying to take.
I am looking forward to your feedback and clarification.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.