Hi Community,
I'm trying to assign value to the drop-down field option and then multiply those values. For example, I have three custom fields, two are drop-down fields and each drop has five options and the third one is a number field.
Drop down fieldA has options are:
1. Apple
2. Orange
3. Banana
4. Pear
5. Kiwi
Drop down fieldB has options are:
1. Potato
2. Tomato
3. Onion
4. Capsicum
5. Broccoli
If the user selects "Apple" from the first dropdown field and it should assign value 1 and value 2 to Orange and so on. Same with the second drop-down field if the user selects Potato it should assign the value 1, value 2 to Tomato, and so on. Then it should multiply fieldA's value by FieldB's value and display results in the third field totalValue. I tried the below Behaviour script but it didn't work. Any idea how can I make it work?
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def fieldA= getFieldById('customfield_17000')
def fieldB= getFieldById('customfield_17001')
def totalScore = getFieldById('customfield_17002')
if(fieldA.value == 'Apple') {
def valueOne = 1
}
if(fieldB.value == 'Onion') {
def valueTwo = 3
}
def valueTotal = valueOne * valueTwo
totalScore.setFormValue(valueTotal )
Thank you