Hi All,
We have this perfectly working script in our workflow and I want to modify it to add one more field (Cleint) to validate to assign the issue to different users. I cannot get this Client field add there right. Can someone help me to understand what's wrong with this script?
We are in JIRA server version 8.13.10
My Requirement is ,
When Global Release is empty, Test phase is Prod or ProdFix and Client is one of CFL/SBA/CYBG , the assignee should goes to one person , the rest should goes in "business prod support"
When global release is not empty it checks test phase again for Doc support option , if not it goes in au.global.relelase
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
//Defining custom fields
String userName;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("Test Phase")
def cfTestPhase = issue.getCustomFieldValue(cf)
def cfp = customFieldManager.getCustomFieldObjectByName("Project Name")
def cfProjectName = issue.getCustomFieldValue(cfp)
def cfg = customFieldManager.getCustomFieldObjectByName("Global Release")
def cfGlobalRelease = issue.getCustomFieldValue(cfg)
def cfc = customFieldManager.getCustomFieldObjectByName("Client")
def cfClient = issue.getCustomFieldValue(cfc)
//Validating values selected in Test Phase and Global Release custom fields.
if (cfGlobalRelease == null) {
switch(cfTestPhase){
case "Prod":
switch(cfClient){
case "CFL":
userName = "e0119168"
break
case "SBA":
userName = "e0119168"
break
case "CYBG":
userName = "e0119168"
break
default :
userName = "business prod support" /* issue.getReporter().getName() */
}
break
}
switch(cfTestPhase){
case "Prod Fix":
switch(cfClient){
case "CFL":
userName = "e0119168"
break;
case "SBA":
userName = "e0119168"
break;
case "CYBG":
userName = "e0119168"
break;
default :
userName = "business prod support"
}
break;
}
}
else {
switch(cfTestPhase){
case "Doc/Helptext":
userName = "e0119138"
break
default :
userName = "au.global.release"
break
}
}
log.error("Username chosen: " + userName)
//Assigning the issue to the value picked by userName
if (! userName.isEmpty() ) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issue.setAssignee(ComponentAccessor.getUserManager().getUserByName(userName))
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
}