Calculate and compare the fields, calculate A+B=C. If the A+B score is less than 9, the priority is

e-Dongyang_Liu July 12, 2024

Calculate and compare the fields, calculate A+B=C. If the A+B score is less than 9, the priority is P1. If it is greater than or equal to 9, the priority is P0. Please guide me!

The code is as follows:

 

 

def sampleListValue = issue.getCustomFieldValue('A')
def sampleListValue2 = issue.getCustomFieldValue('B')
def priority = issue.priority.name

def sampleListValueMap = ['A1':10, 'A2':5, 'A3':2] as Map<String, Long>
def sampleListValue2Map = ['S':3, 'M':2, 'L':1] as Map<String, Long>
def priorityValueMap = ['P0','P1','P2','P3','P4']

if (sampleListValue && sampleListValue2) {
def option1 = sampleListValueMap[sampleListValue.toString()] as Long
def option2 = sampleListValue2Map[sampleListValue2.toString()] as Long
priority = (option1 + option2) as Long
} else {
 0
}

1 answer

3 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.
July 12, 2024

HI @e-Dongyang_Liu 

You could also use automation.

You would need to field to store the C value.

Have an automation trigger based on issue creation or field value change, then sum the values of fields A and B and store in C.

Then re-fetch the issue date and have a condition to check the value of C against the required number value and action to edit or set the priority value.

e-Dongyang_Liu July 12, 2024

Okay, Thank you!

e-Dongyang_Liu July 14, 2024

Too many field values, using automation rules is a bit inappropriate.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.22.6
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events