Calculate value from 2 listed fields to store in other customfield using Automation

thumuluru_shreya
Contributor
January 3, 2025

 I have 2 Custom fields Severity(Select List (single choice)) and Probability(Select List(single choice) and these 2 multiply each other need to store in Score(Number Field)Custom field using Automation. Here severity and Probability are 2 dropdown fields.

Severity values:

1-Major

2-Minor

3-Critical

Probability Values:

1-Critical

2-Major

3-Negligible

Expected how to works:

Severity * Probability=Score

2-Minor * 3-Negligible=6

Please help me in this

 

 

4 answers

1 accepted

1 vote
Answer accepted
Valerie Knapp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2025

Hi @thumuluru_shreya , thanks for your question. 

I'm doing something like this for two of my customers using lookup tables. The benefit of this approach is that you can modify easily the number / weighting associated with each value.

markup_1000019725.png

markup_1000019726.pngmarkup_1000019727.png

 

So, you create a lookup table for each custom field and insert the mapping / weighting. 

Then, in the action, you need to get the custom field ID's and then should be able to insert this calculation

{{#=}}{{Severity.get(issue.customfield_YOURID)}} * {{Probability.get(issue.customfield_YOURID)}}{{/}}

Please have a go on your instance and share your feedback. 

Best wishes

 

thumuluru_shreya
Contributor
January 4, 2025

hi @Valerie Knapp , Thanks for helping. After adding these rules to my rule. No action is performing. Could you please help in this?

 

Thanks

Valerie Knapp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2025

Hi @thumuluru_shreya , what trigger are you using in the rule? Can you show what you've built? And the audit log?

Cheers

thumuluru_shreya
Contributor
January 5, 2025

@Valerie Knapp , Please check I performed an action but there is no results showing on that in audit log.

Screenshot (1036).pngScreenshot (1037).png

Valerie Knapp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2025

Hi @thumuluru_shreya , thanks for sharing the rule. 

Can you try to please to change the trigger to something else, like an issue update or transition and see if you can get it to be called? 

Cheers

thumuluru_shreya
Contributor
January 5, 2025

Hi @Valerie Knapp , I checked these conditions I am getting an error. Could you please help in this

Screenshot (1040).png

Valerie Knapp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2025

Hi @thumuluru_shreya , thanks for sharing the audit log. 

Please can you copy the formula you have in the action for the field RPN? The audit log is saying there is a mistake in the formula syntax. 

Cheers

thumuluru_shreya
Contributor
January 5, 2025

Hi @Valerie Knapp , This is the formula I used

 

{{#=}}{{Severity.get(issue.customfield_10324)}} * {{Occurrence.get(issue.customfield_10325)}}{{/}}

Valerie Knapp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2025

Hi @thumuluru_shreya , thanks. 

Please can you remove the spaces either side of the * and try again?

Cheers

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.
January 5, 2025

Hi @thumuluru_shreya 

That error indicates two things:

First, when accessing the selected value for an option field, the default is to return the option's id and not the value.  When you want to use the value in the get() function calls, that should be:

{{#=}}{{Severity.get(issue.customfield_10324.value)}} * {{Occurrence.get(issue.customfield_10325.value)}}{{/}}

 

Next, from your original question, the values look like this: 1-Major, 2-Minor, etc.  And those values do not match your lookup table keys, so they will not match.

 

This is why I suggested using text functions and a math expression earlier.  Let's assume the first character of each of your select-option fields is a number.  And so the value without using lookup tables would be this:

{{#=}}0{{issue.customfield_10324.value.left(1)}} * 0{{issue.customfield_10325.value.left(1)}}{{/}}

That extracts the first character of each selection, adding a 0 default value at the front, and multiplying to get the result.

 

Kind regards,
Bill

thumuluru_shreya
Contributor
January 5, 2025

Hi @Bill Sheboy , Thanks for Support! I got expected output.

Here I have some modification to My question. Could you please help in this.

Q:I have 2 Customfields as Severity and Occurrence. These 2 customfields are dropdown fields. It Contains

Severity contains the dropdown values as(Negligible, Minor and Major). 

Occurrence contains the dropdown values as (Critical, Probable and Improbable)

Score is the numeric customfield to store the multiplication of both severity and occurrence

Ex:

Scenario 1:

If user selects

severity as Negligible (Internally it assumes as 1)

Occurrence as Probable (Internally it assumes as 2)

So in score the result will calculate as 1*2=2

Scenario 2:

If user selects

Severity as Major( Internally it assumes as 3)

Occurrence as Critical(Internally it assumes as 1)

So in score the result will calculate as 3*1= 3

Expected output:

We took 2 customfields as dropdown list and we are expecting the output as multiplication of both customfields as Numeric. And this numeric multiplication calculation of both dropdown list will happen internally. Eralier we have severity and occurrence both as numeric but now both are changed as dropdown list.

 

Finally the calculation should happen internally.

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.
January 5, 2025

Thank you for that information, and that is different than the question you originally asked.

As the custom field options just have the text (e.g., Negligible, Minor, and Major) the lookup tables are needed as @Valerie Knapp suggested or you could use conditional logic.

Using the lookup tables, the expression would be what I noted using the value attribute:

{{#=}}{{Severity.get(issue.customfield_10324.value)}} * {{Occurrence.get(issue.customfield_10325.value)}}{{/}}

Again, the keys to making this work are what Valerie noted:

  • exactly matching the option values to the lookup table keys,
  • confirming you have the correct custom field IDs needed, and
  • deciding what to do if the fields have no option selected.

 

Like Valerie Knapp likes this
thumuluru_shreya
Contributor
January 5, 2025

Hi @Bill Sheboy  and @Valerie Knapp ,Thanks for your support. I got now.

Cheers

Like # people like this
thumuluru_shreya
Contributor
January 5, 2025

Hi @Bill Sheboy  and @Valerie Knapp . I have doubt in saving name in look up variable. We cannot save look up variable name as Post Occurrence or Occurrence (Post). Because I need to use 2 Occurrences those are Pre Occurrence and Post Occurrence. But I am not able to save in Look up variable. Is there any work around for this?Screenshot (1041).png

Kumar_rajarapu January 5, 2025

Hi @thumuluru_shreya , Remove Space between the words to save

thumuluru_shreya
Contributor
January 5, 2025

@Kumar_rajarapu , Space should be there in my requirement. How to handle this error in look up table?

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.
January 6, 2025

Hi @thumuluru_shreya 

You can't as stated by @Kumar_rajarapu and the warning message says it also.

You can only use alphabetic characters, so no spaces or other special signs.

2 votes
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.
January 3, 2025

Whenever you ask for help with an Automation Rule it will help us to help you if you provide:

1. what type of project is this (e.g., company-managed, team-managed, etc.), 

2. images that show your complete rule.

3. images showing the details of the actions/conditions/branches.

4. images showing the Audit Log details for the rule execution.

5. images showing the relevant data in an image that is part of the rule execution.

6. Explain where the issue is.

These questions are not for not willing to help, but to have community members learn on how automation works.

Not just to provide a full solution, which would not help to understand what the automation is doing, but to have members understand what a rule is doing, if in need of change or error.

1 vote
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.
January 3, 2025

Hi @thumuluru_shreya 

As @Marc - Devoteam suggests, context is important for automation rule questions: please post the complete rule, action details, and audit log details to help the community provide suggestions.

Until we see those...

If the values you show are in fact the values of the custom fields, you could use:

To make this work, you must use the correct smart values (or custom field ID values).  To find those, use this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Kind regards,
Bill

0 votes
Kumar_rajarapu January 3, 2025

Hi @thumuluru_shreya ,

Create Automation Rule:

Trigger: Field value Updated.( Add fields -Severity, Probability)

Condition: (Optional) Set conditions if necessary

Action: Edit Issue Field (Add field -Score)--choose set value(add below JSON Script)

Smart Value Calculation: Use smart values to calculate the score

Add JSON script

[" {
"fields": {
"Score": "{{#=}}(
(if(issue.Severity == "Major", 1, if(issue.Severity == "Minor", 2, 3))) *
(if(issue.Probability == "Critical", 1, if(issue.Probability == "Major", 2, 3)))
){{/}}"
}
}"]

Example:

2 (Minor) * 3 (Negligible) = 6 (Score)

 

Regards,

kumar

 

thumuluru_shreya
Contributor
January 3, 2025

@Kumar_rajarapu , Could you please explain or send screenshot from JSON where I need to add this step exactly it will be helpful for me

Kumar_rajarapu January 3, 2025

Actually I'm not able take the Screenshot

Action component: choose Edit Issue Field (Add field - Score) 

In Action, after selecting the field in 'Edit issue',

click on 'More options' below

In the 'Additional fields' box, add the JSON script.

 

 

Kumar_rajarapu January 3, 2025

Edit issue Delete component

Set values for fields on the issue. Simply add the fields you want to edit.

More optionS
Send notifications?
This rule should send emails
Additional fields
 {
"fields": {
"Score": "{{#=}}(
(if(issue.Severity == "Major", 1, if(issue.Severity == "Minor", 2, 3))) *
(if(issue.Probability == "Critical", 1, if(issue.Probability == "Major", 2, 3)))
){{/}}"
}
}
You may specify additional field values to be set using a JSON object as documented. The fields you specify must be present
thumuluru_shreya
Contributor
January 3, 2025

@Kumkum , Hi Kumar what are the smart values need to add ? Then what is the smart value section? Is it necessary to add in this automation rule

thumuluru_shreya
Contributor
January 3, 2025

@Kumar_rajarapu I copied same rule but I am getting error. Could you please help in this

Screenshot (1032).png

Suggest an answer

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

Atlassian Community Events