Hello!
I have custom field called Test Phase which is a single select list. I want to assign the issue to user AA when "Prod" selected and to user BB when "Dev" selected in Test Phase.
I am new to script runner and I tried following script and failed. Can you please check and let me know the problem of this script?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
String userName;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("Test Phase")
def cfTestPhase = issue.getCustomFieldValue(cf)
switch(issue.getCustomFieldValue(cfTestPhase)){
case "Prod": userName = "AA";break;
case "DEV": userName = "BB";break;
}
log.error(userName)
log.error(issue.getCustomFieldValue(cfTestPhase));
issue.setAssignee(ComponentAccessor.getUserManager().getUserByName(userName))