Any quick tips? I know the groovy script runner is out there -- but my version doesn't have something for just assigning issues (though I see that some of the scripts, like the fast-track workflow listener, allows users to also assign an issue..)
Basically, when issues are normally created in this particular queue, it automatically gets assigned to the project lead.
I want to maintain this functionality, but I want the issue to be assigned to another user based on a value in a select list custom field.
Help much appreciated. I'm assuming some sort of listener is needed..?
Hi Bryan,
Please give a try to this third plugin known as User Picker From Project Role - Issue Alternative Assignee.
Good luck
thanks -- looks promising. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In custom script listener hooked on Create event you can use any of the issue fields, built-in or custom, to do what ever you want:
like assign to hardcoded person based on priority, issue type, etc.
Here an example of complete Listener class file you can modify for your task.
Many people are asking how to start with custom listeners, how to name a class, where to put a file, etc.
I hope this sample will provide some guidance. Just copy it to a file <class name>.groovy and copy to a place where groovy runner can find it (check out this answer)
import java.util.* import java.sql.Timestamp import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.* import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueInputParameters import com.atlassian.jira.issue.link.* import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.CustomFieldManager import org.apache.log4j.Category import com.atlassian.crowd.embedded.api.User import com.atlassian.plugin.PluginAccessor import com.atlassian.jira.bc.project.ProjectService import com.atlassian.jira.user.util.UserUtil //rename your listener class as needed class AutoIssueAssignerListener extends AbstractIssueEventListener { Category log = Category.getInstance(LoggerService.class) @Override void workflowEvent(IssueEvent event) { // only one central way... this.customEvent(event) } ComponentManager componentManager = ComponentManager.getInstance() @Override void customEvent(IssueEvent event) { // set explicit to debug log.setLevel(org.apache.log4j.Level.DEBUG) // remove for production log.debug "Groovy Service Class name: ${this.getClass().getName()}" log.debug "Event: \"${ComponentManager.instance.eventTypeManager.eventTypesMap[event.getEventTypeId()].name}\" fired for ${event.issue}" // Here you should put any restrictions for this task like // only for special issue types or similar Issue issue = event.issue User user = issue.getAssigneeUser() // if (issue.isSubTask()) { return } def customFieldManager = ComponentManager.getInstance().getCustomFieldManager() def cfCategory = customFieldManager.getCustomFieldObjectByName("Category") //use your custom field name here def category = issue.getCustomFieldValue(cfCategory) def userToReassign = issue.getAssignee() UserUtil userUtil = componentManager.getUserUtil() switch (category) { case "One":
userToReassign = userUtil.getUserObject("jsmith")
break case "Two":
userToReassign = issue.getProjectObject().getLead()
break } issue.setAssignee(userToReassign) issue.store() } log.debug "Listener ${this.getClass().getName()} completed" } }
It is not tested. Just removed my stuff from working listener and threw in few lines of code that might be relevant to your task
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Updated my answer with code sample
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to rule it out - I take it components aren't suitable? (i.e. assign to component lead)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, that approach wont work due to how our solution is set up.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.