For example, I have 3 fields called
I need a script field that calculate values numbers.
ex Sensitive=Yes, Automated=No, Region=USA Total values 5+5+8 = 10 should be on scripted field.
import com.atlassian.jira.component.ComponentAccessordef CustomFieldManager = ComponentAccessor.getCustomFieldManager()def a = CustomFieldManager.getCustomFieldObject(xxxxx)def b = CustomFieldManager.getCustomFieldObject(xxxxx)def c = CustomFieldManager.getCustomFieldObject(xxxxx)def aValue = issue.getCustomFieldValue(a)def bValue = issue.getCustomFieldValue(b)def cValue = issue.getCustomFieldValue(c)int aDigitint bDigitint cDigitswitch(aValue){ case "Yes": aDigit=5 break case "No": aDigit=3 break default: aDigit=0 }switch(bValue){ case "Yes": bDigit=10 break case "No": bDigit=5 break default: bDigit=0 }switch(cValue){ case "UK": cDigit=8 break case "Africa": cDigit=7 break default: cDigit=0 }int sum = aDigit + bDigit + cDigitreturn sum
Hi @Arkadiusz Baka , Thanks for your reply and code,
It worked for single list field but for multi select field it is not working, I have modified the code to get multi select field value but no luck,
Can you help me that same?
Thanks
Multi select field is a list. Try something like that:
HashMap<String, Integer> country = new HashMap<String, Integer>();// Add keys and values (country , value)country.put("USA", 8);country.put("UK", 7);country.put("Africa", 5);int count=0;for (String key:list) {if (country.containsKey(key)){count+=country.get(key);}}
Where list is getting form multi select field
Hi @Arkadiusz Baka ,
For my case "Sensitive" and "Automated" is single list and Country is multi select field.
Help me the same.
It looks like you're new here. Sign in or register to get started.