Hi,
i found a script that calculates the sum of 5 custom fields and devides it by 5, now im struggling to actually display this Value on a custom field in the Issue. Can anybody help me with the Code ?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
def issue = ComponentAccessor.getIssueManager().getIssueObject("ID-29")
def result_CF = "customfield_19921"
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
List<String> fieldNames = ["customfield_19824","customfield_19827", "customfield_19825", "customfield_19828", "customfield_19826"]
List<Integer> scores = []
for (String field : fieldNames){
def cf = customFieldManager.getCustomFieldObject(field)
scores.add((Integer) issue.getCustomFieldValue(cf)?: 0)
}
//return scores.sum {it} / 5
result_CF = scores.sum {it} / 5
return result_CF