You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.
Join groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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.bc.issue.search.SearchService
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
df.applyPattern("###,##0.00")
// edit this query to suit
def query = jqlQueryParser.parseQuery("issueFunction in subtasksOf(\"issuekey=" + issue.key + "\",\"is children of\")")
def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
log.debug("Total issues: ${search.total}")
def Progresso = 0
def StatusFinalizado = 0
def Total = 0
def textoCategoria = ""
search.results.each { documentIssue ->
log.debug(documentIssue.key)
// if you need a mutable issue you can do:
def issueJira = issueManager.getIssueObject(documentIssue.id)
//ajuste para não entrar os itens removed
if (!issueJira.issueType.isSubTask() && issueJira.issueType.name != "Story" && issueJira.getStatus().name != "Removed")
{
/// textoCategoria = textoCategoria + " - " + issueJira.issueType.name
if(issueJira.getStatus().getStatusCategory().name == "Complete" && issueJira.getStatus().name != "Removed" ) {
(StatusFinalizado++)
textoCategoria = textoCategoria + " - " + issueJira.issueType.name
}
(Total++ )
}
}
if (Total > 0){
//Total de Features em Andamento ou finalizado
Progresso = (((int)StatusFinalizado) / (int)Total) * 100;
}
//return (int)StatusFinalizado
return df.format(Progresso) + "%"
//StatusFinalizado
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...
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.