Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • 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
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?
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

How to get a completion percentage of a Story

I need to create a custom field that shows the completion percentage of a Story. For example, if an story have 4 sub-tasks and one of them are "done" this field must show 25%
But I am have some difficulties with this script:


Can someone help me with this? What's wrong?


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import java.text.DecimalFormat
import java.text.NumberFormat

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
DecimalFormat df = (DecimalFormat)nf

// edit this query to suit
def query = jqlQueryParser.parseQuery("issueFunction in subtasksOf(\"issuekey=" + issue.key + "\",\"is children of\")")
def search =, query, PagerFilter.getUnlimitedFilter())

log.debug("Total issues: ${}")

def Progresso = 0
def StatusFinalizado = 0
def Total = 0
def textoCategoria = ""

search.results.each { documentIssue ->

// if you need a mutable issue you can do:
def issueJira = issueManager.getIssueObject(

//ajuste para não entrar os itens removed
if (!issueJira.issueType.isSubTask() && != "Story" && issueJira.getStatus().name != "Removed")

/// textoCategoria = textoCategoria + " - " +

if(issueJira.getStatus().getStatusCategory().name == "Complete" && issueJira.getStatus().name != "Removed" ) {
textoCategoria = textoCategoria + " - " +

(Total++ )

if (Total > 0){
//Total de Features em Andamento ou finalizado
Progresso = (((int)StatusFinalizado) / (int)Total) * 100;

//return (int)StatusFinalizado

return df.format(Progresso) + "%"



1 answer

1 accepted

0 votes
Answer accepted


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

153 views 9 10
Read article

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