I have set up an automated rule in our Jira instance so that the custom field 'Percentage completed' on an Epic will update based on the status of the Epic's child work items. So, when a Story, Task, Sub-task, Bug, Bug Sub-Task, or UAT Bug that is parented to an Epic has the Status updated to Removed, Done, Resolved, Rejected, or Closed, the 'Percentage completed' field will automatically update on the Epic.
However, I have manually updated a Story that is parented to an Epic to 'Done' to check if the rule works, and the percentage has not updated. I have checked the audit log of the rule and it appears to have run, stating the epic has been updated, but the 'Percentage completed' field still stats 0%.
To troubleshoot, I have checked the type of the custom field is correct (set to Number Field), and updated the Actor of the rule to myself, as I wondered if it was a permissions issue with the Automation for Jira actor.
The rule is:
Trigger: When work item transitioned to Removed, Done, Resolved, Rejected, Closed
Issue type is one of Story, Task, Sub-task, Bug, Bug Sub-Task, UAT Bug
Branch: For Parent
Then: Lookup work items:
parent = {{issue.key}}
And: Lookup work items:
parent = {{issue.key}} AND status in (Resolved, Done, Removed, Closed, Rejected)
And: Create variable:
Variable name = totalChildren
{{lookupIssues.size|0}}
And: Create variable:
Variable name = closedChildren
{{lookupIssues_1.size|0}}
If: Compare two values
First value = {{totalChildren}}
Condition = greater than
Second value = 0
Then: Create variable
Variable name = percentComplete
{{#=}}{{closedChildren}} / {{totalChildren}} * 100{{/}}
And: Edit work item fields
Field = Percentage completed
{{percentComplete}}
Can anyone provide some suggestions or pointers as to why this isn't updating the field? Eventually I would like to create the same rule to update the Features and Initiatives we have set up
Any help much appreciated
Thanks
Hello @Sarah Cheyne
Welcome to the Atlassian community.
Each execution of a Lookup Issues action overwrites the result of the previous Lookup Issues action. You cannot execute multiple such actions and the reference the results of one versus another using {{lookupIssues_#}}
After the first Lookup Issues action you have to use the Create Variable action to create you totalChildren variable.
Then you can execute the next Lookup Issues action and create the closedChildren variable.
As it stands your current first create variable action is looking at the results of your second Lookup Issues action.
And your second create variable action is getting the value 0 because there is no such smart value as {{lookupIssues_1}}
Hi Trudy
Thanks for your help. I switched the order and renamed the variable for closed Children so it reads as follows:
Trigger: When work item transitioned to Removed, Done, Resolved, Rejected, Closed
Issue type is one of Story, Task, Sub-task, Bug, Bug Sub-Task, UAT Bug
Branch: For Parent
Then: Lookup work items:
parent = {{issue.key}}
And: Create variable:
Variable name = totalChildren
{{lookupIssues.size|0}}
And: Lookup work items:
parent = {{issue.key}} AND status in (Resolved, Done, Removed, Closed, Rejected)
And: Create variable:
Variable name = closedChildren
{{lookupIssues.size|0}}
If: Compare two values
First value = {{totalChildren}}
Condition = greater than
Second value = 0
Then: Create variable
Variable name = percentComplete
{{#=}}{{closedChildren}} / {{totalChildren}} * 100{{/}}
And: Edit work item fields
Field = Percentage completed
{{percentComplete}}
The field is now updating on the epic. Do you have any suggestions to round the number so it displays as 0 decimal place? E.g. 3.85 would be 4%
I have tried to add the rounding to the edit work item field so it reads as {{percentComplete.round(0)}} but when I do that the field doesn't update at all
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The round function doesn't take any inputs. Try removing (0)
Ref: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/#Round
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sarah Cheyne -- Welcome to the Atlassian Community!
Yes, and...to the solution you already have worked out with Trudy: a couple of things to consider:
a) With so many "done" status values, you may want to use a single lookup and check the statusCategory instead using list-filtering. That will ensure if the status values change in the future, the rule will still work. For example:
{{#=}}ROUND( ( 0{{#lookupIssues}}{{#if(equals(status.statusCategory.name,"Done"))}}+1{{/}}{{/}} ) / {{lookupIssues.size|0}} * 100, 0){{/}}
That works by...
b) Your initial rule handles the case of the child work items transitioning status. And, there are several other possible things which could change and impact the percentage. Please consider how accurately you want the number, when you want it updated, and then decide if you want to add other rules to help. Those include at least:
Some of these cases can be combined by adding more conditions to rules.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bill! I have updated the automation rule based on your suggestion above
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.