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)
Hello @shivprasad hattaraki
Which version of jira do you use?
try this code
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
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 = ComponentAccessor.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}."
def userManager = ComponentAccessor.getUserManager()
switch (category) {
case "Bengaluru":
log.debug "Getting user for Desktop category."
userToReassign = userManager.getUserByKey("shivprasad.hattaraki")
break
case "Mumbai":
log.debug "Getting user for Network category."
userToReassign = userManager.getUserByKey("avinash.deshpande")
break
}
log.debug "Setting user to ${userToReassign}."
issue.setAssignee(userToReassign)
and place it in postfunction, before change history transition
Thank you Mark
Its working fine now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
I want to assign an issue automatically to some user based on description entries and auto-set labels to that issue. Can this be possible using the post function script?
Regards,
Satya Prasad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
THANKS A TONN!
I have used the above code for my application/project in JIRA.
It worked :) :) :)
very much grateful to you.
thanks again
Sridevi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.