Hello and Help... I'm new to groovy and the only one in my group that can work on this.
We have a custom field called 'agile-team' that we would like to populate based on another field called 'Product/s'. Product/s is a multi select field during issue creation. This example is to check a list of Abend-AID products and if a match and if the agile-team is not already 'Abend-AID' then set it to 'Abend-AID'
Here is a small part of what I've got. I'm concerned about the updateValue code, is this correct? or are we better with the setCustomFieldValue function?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
Issue issue = issue
def numproducts = ((getCustomFieldValue("Product/s")?.size())?:0) as Integer
//println "numproducts="+numproducts;
def products = getCustomFieldValue("Product/s")
def agile-team = customFieldManager.getCustomFieldObjectByName("Agile Team/s")
//multi-user custom field to be populated with product families involved in the issue
CustomField productLines = customFieldManager.getCustomFieldObjectByName("Product Line/s");
def result = ""
def i =0
for (i=0; i < numproducts; i++){
def product = products[i].toString()
switch (product) {
case ["Abend-AID","Abend-AID Common","Abend-AID Fault Analytics","Abend-AID Fault Analytics Distributed","Abend-AID for CICS","Abend-AID XLS"]:
if (result.contains("Abend-AID")) {break}
else {
result = agile-team.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(agile-team), "Abend-AID"),new DefaultIssueChangeHolder())
break }
Thanks, This community is the best!