I have select list Custom field "Po Region" , it has 2 options "Bengaluru" and "Mumbai" if bengaluru option selected it has to assign to "user A" else Mumbai selected assign to "user B"
I have worked with script runner
1) script Listener
2) post function
Both didn't work
I have this following code
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.user.util.UserUtil
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
log.debug "Starting postfunction..."
if (issue.isSubTask()) {
log.debug "Issue is subtask, leaving."
return
}
def customFieldManager = componentManager.getCustomFieldManager()
def cfCategory = customFieldManager.getCustomFieldObjectByName("Po Region")
log.debug "Found customfield ${cfCategory}."
def category = (issue?.getCustomFieldValue(cfCategory) as Option)?.value
log.debug "Got category ${category}."
def userToReassign = issue.getAssignee()
log.debug "Got assignee ${userToReassign}."
UserUtil userUtil = componentManager.getUserUtil()
switch (category) {
case "Bengaluru":
log.debug "Getting user for Desktop category."
userToReassign = userUtil.getUserObject("shivprasad.hattaraki")
break
case "Mumbai":
log.debug "Getting user for Network category."
userToReassign = userUtil.getUserObject("avinash.deshpande")
break
}
log.debug "Setting user to ${userToReassign}."
issue.setAssignee(userToReassign)
issue.store()
It doesn't work , plz help me on this problem.
This is log details
Time (on server): Thu Jul 19 2018 10:41:05 GMT+0530 (India Standard Time)
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2018-07-19 10:41:05,815 DEBUG [workflow.ScriptWorkflowFunction]: Starting postfunction...
2018-07-19 10:41:05,828 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-07-19 10:41:05,828 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
groovy.lang.MissingPropertyException: No such property: componentManager for class: Script950
at Script950.run(Script950.groovy:13)