I created a custom field named % complete to our User Stories. I'm attempting to update % complete to the number of sub-tasks with a status of "done" (statusCategory.key = "done") divided by the total number of sub-tasks each time a sub-task is updated.
I can calculate the number of sub-tasks but when it comes to determining the number of "done" sub-tasks I always get a value of zero.
In an effort to resolve this issue, I've simplified my rule to use the use cases from our most current sprint. I then created a variable for the total number of sub-tasks
totalSubtasks {{issue.subtasks.size}}
Next, I tried to determine the number of "done" subtasks several ways. I have a variable for each:
doneSubtasks {{issue.subtasks.where(statusCategory.key = "done").size}}
TOTALDONE {{issue.subtasks.where(status.name = "DONE").size}}
Each time these come back equaling zero,
My original attempt was a little more complicated. A screenshot of the rule is below. Again, each time the number of sub-tasks with a status of "done" is zero.
Any help is greatly appreciated.
Hi @Greg Aurand -- Welcome to the Atlassian Community!
There is no where() function for smart values, and there is no key attribute for the statusCategory.
Which source suggested those to you for rules as it is incorrect?
Next, your rule does not need the Rule Group structure, and I recommend not using that new feature unless absolutely necessary.
Assuming you want to count percentage complete by counts, and your work item has subtasks, this expression would work, with extra spacing added to help explain it:
{{#=}}
ROUND(
{{#=}} (0
{{#issue.subtasks}}
{{#if(equals(fields.status.statusCategory.name, "Done"))}}
+1
{{/}}
{{/}}
)
{{/}}
/ {{issue.subtasks.size|0}}
* 100
, 0)
{{/}}
How that works is, explaining from the inside toward the outside:
Kind regards,
Bill
Hi @Greg Aurand,
Welcome to Atlassian Community!
You cannot use JQL as part of your smart value, that is why they return as empty. What you could do is a lookup work items for done sub tasks linked to the current work item and then use {{lookupIssues.size}} to get the number of done sub-tasks.
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.