Hi All,
I'm trying to calculate 3 (single select drop down fields) and populate in a number field.
Here is the sample script, what i have tried. can anyone help me with the snippet for score calculation.
Busniess Priority - Single select drop option with values (1,2,3)
Severity - Single select drop option with values (1,2,3)
Mandatory - Single select drop option with values (1,2)
Score - output field (field type number)
def customFields = get("/rest/api/2/field")
.header('Content-Type', 'application/json')
.asObject(Map)
.body
def fields = issue.fields as Map
//def output
// Get the Custom field to get the option value from
def customField1 = get("/rest/api/2/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Busniess Priority'
} as Map
def customField2 = get("/rest/api/2/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Severity'
} as Map
def customField3 = get("/rest/api/2/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Mandatory'
} as Map
// Extract and store the option from the custom field
def value1 = (fields[customField1.id] as Map).value
def value2 = (fields[customField2.id] as Map).value
def value3 = (fields[customField3.id] as Map).value
def outputCfId
def output = value1 * value2 * value3
put("/rest/api/2/issue/${issue.key}")
//.queryString("overrideScreenSecurity", Boolean.TRUE)
.header("Content-Type", "application/json")
.body([
fields:[
(outputCfId): output
]
])
.asString()
TIA!