Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Up Jira Automation to Calculate 'Total Score' from Custom Fields

Fernando Garcia December 9, 2023

In Jira Cloud, I have 3 custom fields: PII, PCI and PFI.

Each can be answered Yes or No. If Yes, value = 2 and if No, value = 1.

I have a fourth customer number field named Total Risk Score.

Using Automation, I want the Total Risk Score to equal the values from the first 3 custom fields.

2 answers

0 votes
Bill Sheboy
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.
December 10, 2023

Hi @Fernando Garcia 

When accessing a selection custom field, the value attribute may be used to access it.  Otherwise the default attribute is returned, which is the id value of the selection.

For example, to get the value the user sees, try this:

{{issue.mySelectionField.value}}

For your case, that would return either "Yes" or "No".  Please update your rule accordingly, or your conditional logic (testing the field) will only return null values.

 

One more thing to check...Smart values are name, spacing, and case-sensitive.  And they often do not match the displayed name on the issue pages.  To confirm the correct smart values for a field, please use this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Kind regards,
Bill

0 votes
Tim Kopperud
Community Champion
December 10, 2023

Hi @Fernando Garcia, welcome to the Atlassian Community. You can use variables and smart values for this.

Set 1 or 2 into a variable based on Yes or No, like this

image.png

Create one variable for each.

PII

{{#if(equals(issue.PII, "Yes"))}}2{{/}}{{#if(equals(issue.PII, "No"))}}1{{/}}

PCI

{{#if(equals(issue.PCI, "Yes"))}}2{{/}}{{#if(equals(issue.PCI, "No"))}}1{{/}}

PFI

{{#if(equals(issue.PFI, "Yes"))}}2{{/}}{{#if(equals(issue.PFI, "No"))}}1{{/}}

Then you can use math expression to calculate, like this example

{{#=}} {{varPII}} + {{varPCI}} + {{varPFI}} {{/}}

This will sumarize the three variables. 

I'm not fully sure if you mean "sum" or something else when you say "...Total Risk Score to equal the values", but I used sum in this example. 

The rule might look something like this

image.png

I have used the Summary field in my example (see yellow marking), so you should replace this with your field Total Risk Score. Also use a Rule trigger and add a filter based on your specific need.

TimK.

Fernando Garcia December 10, 2023

Hi Tim,

 

thank you so much for your detailed response. I get this error when running my new rule: error rendering smart value when executing this rule: missing parameters for operator +u: +

Tim Kopperud
Community Champion
December 10, 2023

Hi @Fernando Garcia. Can you attach images of the error and the rule?

TimK 

Fernando Garcia December 10, 2023

Thank you so much for the detailed example. I tried building out what you recommended but still received this error:

Edit Issue

Error rendering smart-values when executing this rule:

Missing parameter(s) for operator +u: +

Automation:

 

Smart Value/Variable 1: {{#if(equals(issue.fields.Information Privacy PCI, "Yes"))}}2{{/}}{{#if(equals(issue.fields. Information Privacy PCI, "No"))}}1{{/}}

 

 

 

Smart Value/Variable 2:{{#if(equals(issue.fields.Information Privacy PII, "Yes"))}}2{{/}}{{#if(equals(issue.fields. Information Privacy PII, "No"))}}1{{/}}

 

Edit Issue Rule:{{#=}} {{varPII}} + {{varPCI}} {{/}IMG_0369.pngIMG_0368.pngIMG_0367.png

Tim Kopperud
Community Champion
December 10, 2023

Hi @Fernando Garcia, try removing .fields from issue.fields.

It should be issue.Information Privacy PII

TimK 

Fernando Garcia December 10, 2023

Hi Tim,

I get the same error: 

Edit issue

Error rendering smart-values when executing this rule:

Missing parameter(s) for operator +u: +

Tim Kopperud
Community Champion
December 10, 2023

Hi @Fernando Garcia, I see that you have used other variable names on the math function than the variables that you created. The math function will not work if the variable names doesn't exist. 

In the math function you are using varPCI and varPII (ref yellow markings)

image.png

But when you created the variables you used only PCI (not varPCI) and PII (not varPII) as shown below (ref yellow marking)

image.png

I used e.g., varPCI as the variable name in my example because I thought you had a field called PCI. You might call the varible PCI if you want but when you use the variable other places like in the match function it must match.

In your match function you are referring to varables that doesn't exists. 

Let me know how it works when you have updated this. 

TimK. 

Imran Khan February 20, 2024

Hi Tim

 

When I added log action for the variable the output i'm getting is null, and editing issues is also throwing error

Imran Khan February 20, 2024

Risk.png

Imran Khan February 20, 2024

{{#if(equals(issue.What is the impact to users and/or Customers?, "None"))}}0{{/}}{{#if(equals(issue.What is the impact to users and/or Customers?, "No Impact"))}}5{{/}}{{#if(equals(issue.What is the impact to users and/or Customers?, "Loss of Redundancy"))}}15{{/}}{{#if(equals(issue.What is the impact to users and/or Customers?, "Downtime"))}}20{{/}}

for example the variable written for fone and getting below errorRisk1.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events