Need to calculate a value in a field from two other fields

Kathy Dickason
Contributor
July 16, 2024

I have these fields with numerical values:

  • Total Points
  • Total Resolved Points
  • Total Unresolved Points

I would like to auto-populate another field named Percent Completed by dividing Total Resolved Points by Total Points then multiplying by 100.   Can you tell me what type of field to create to house this and how to populate it with a formula to show the Percent Complete?  I have ScriptRunner but no other plug-in. I am not a developer and cannot code, so really need help.

 

3 answers

1 accepted

2 votes
Answer accepted
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2024

Hi @Kathy Dickason 

You can create an automation rule and have an edit action the looks like:

{{#=}}{{issue.Total Resolved Points}} / {{issue.Total Points}} * 100{{/}}

Kathy Dickason
Contributor
July 17, 2024

Okay, this (above) worked for my Epic % Complete field.  Thank you!  Here's my next problem, however:

This automation runs when a story is updated.  When the story is updated to add an Epic Link, the story points from it are added to the field Total Points field on the Epic screen for the Epic it is linked to).  This works great, except in the circumstances when someone changes the Epic Link on the Story or deletes the Epic Link from the Story.  When that happens, the Lookup issues portion of the Automation no longer can find the Epic the story was assigned to (since it changed) so the story point total in the Epic remains at the same number even though the story is no longer linked to it.   

I can fix this by going into one of the stories that is still assigned to the Epic and making any kind of update to the form, which triggers the rule and point calculation again.   But when I try to automate this (add then remove a label to every story, for instance, via automation), the update to the issue doesn't trigger the rule calculation.  Why does an automated update not work, but a manual update does?  Any ideas on what I can do? 

epic_link_automation.png

 

Kathy Dickason
Contributor
July 17, 2024

To clarify, I want to force an update to stories with Epic Links via Automation, but when I do things like add a Label or add a Comment to the story via Automation, that does not kick off the Automation pictured above.  I don't understand why!  If I make the same change manually to the story with the Epic Link, the Automation above kicks off.

Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2024

Hi @Kathy Dickason 

Check the option:

"Check to allow other rule actions to trigger this rule. Only enable this if you need this rule to execute in response to another rule"

This option can be found in the rule details.

Kathy Dickason
Contributor
July 18, 2024

THANK YOU!!!!!!!   I can't believe how much time I wasted.  You're wonderful!!!!

 

Like Marc - Devoteam likes this
Kathy Dickason
Contributor
August 30, 2024

@Marc - Devoteam I'm hoping you can help me.  My automation using 
{{#=}}{{issue.Total Resolved Points}} / {{issue.Total Points}} * 100{{/}}  works in some cases, then does not.  I'm getting this in the Audit log when it does not (see screen cap).  Any ideas?  What is strange is that it sometimes works (see second screen cap). Screenshot 2024-08-30 140509.jpgScreenshot 2024-08-30 140728.jpg

Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 2, 2024

Hi @Kathy Dickason 

This will occur when you have the incorrect smart value for the field, as it becomes an empty/null value in the expression. 

So if the field has no value, this can occur.

You could set your calculation like this:

{{#=}}{{issue.Total Resolved Points|1}} / {{issue.Total Points|1}} * 100{{/}}

The the field always has 1 as default in the calculation, if the field is empty in an issue. When performing the automation.

Kathy Dickason
Contributor
September 3, 2024

You are correct again!  My Automation to calculate the Total Resolved Points was entered in a way that after the result was calculated I set the automation to clear the field mistakenly!  I just had to fix that and it all appears to be working now.  You're so wonderful!!

Like Marc - Devoteam likes this
0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 16, 2024

Hello @Kathy Dickason 

In your post tags you have indicated both Data Center and Server. Which are you actually using, and what version?

Are you going to want to use that Percent Complete field within Filters?

As alluded to by the reference @Nicolas Grossi provided, Automation for Jira could be used to accomplish this. However, the functionality available differs based on the product you are using and the version of the product. Here is the home page for the latest documentation of the Automation feature in Jira Data Center.

https://confluence.atlassian.com/automation/

Jira Server/Data Center does not natively offer scripted or calculated fields, so Automation is a native method for accomplishing your requirement. You can also use the field in Filters if you populate it with this method.

Not all users can create Automation Rules. You may need to get help from your Project Administrator or Jira Administrators to get the rule created.

 

You said you have ScriptRunner. You could alternately use a Script Field for Percent Complete. 

Kathy Dickason
Contributor
July 17, 2024

Data Center.

Kathy Dickason
Contributor
July 17, 2024

I would need to know what to type in the Script Field... Unfortunately, I'm not a software engineer.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events