Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Auto assign based on custom field.


I'm trying to use these script for Auto Assign based on the custom field"Drop-down menu"

but it's not working with me.

Ps: Jira software version 7.12.1 and the post function is Scripted (Groovy) operation on issue (JMWE add-on) 


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
import com.atlassian.jira.event.type.EventDispatchOption

String userName;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("Departments")
def cfDepartments = issue.getCustomFieldValue(cf)
case "Influencer Relations": userName = "INF_BP";break;
case "Client Services": userName = "CS_BP";break;

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)





import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import org.apache.log4j.Level


log.debug "Starting postfunction..."
if (issue.isSubTask()) {
log.debug "Issue is subtask, leaving."

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfCategory = customFieldManager.getCustomFieldObjectByName("Departments")
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 "Influencer Relations":

userToReassign = userManager.getUserByKey("INF_BP")
case "Client Services":

userToReassign = userManager.getUserByKey("CS_BP")
log.debug "Setting user to ${userToReassign}."


2 answers

Any help?

0 votes
John Funk Community Leader Jan 07, 2020

Hey @SmaatHub - can you describe exactly what you are trying to do without the code?

I'm trying to Auto Assign the ticket based on the custom field"Drop-down menu"

Ex: if the requester of ticket chooses his department from the drop-down menu like Client engagement the assignee goes to CE-BP and so on in other choices.


John Funk Community Leader Jan 08, 2020

I know that can easily be done with the Automation For Jira add-on. If the value of a field changes, you can have different actions that take place - for instance, setting the value of another field. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,664 views 22 33
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you