Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Assign the jira ticket based on single selection lsit field value

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2021

Hi Team,

 I have requirement to assign the jria ticket  depends on the selection list. Could you please suggest that how to implement this ?

 Example , we have Department field with single selection list

  • Technology   
  • Marketing/Sales 
  • Customer Success 
  • HR/Corporate Services
  • Finance/Legal 

If user selects Technology while creating the jria ticket , it should assign the jira ticket to abc@xxx.com, if user selects Marketing/Sales, it should assign the jira ticket to aabc@xxx.com, etc

Thanks!

2 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
November 17, 2021

Hi @Lakshmi CH 

with JMWE, you can simply use a Set Field Value post-function on the Create transition, with a value (of type "Groovy Expression") like:

switch (issue.get("Department")) {
case "Technology": return "usera";
case "Marketing/Sales": return "userb";
default: return null; //others are unassigned
//etc
}

Note that usera, userb, etc. must be Jira usernames, i.e. what the user uses for their login (which might be different from their email address)

0 votes
Gaurav
Community Champion
November 17, 2021

Hello @Lakshmi CH 

This use case can be accomplished by the use of Automation with a simple If-Else construct. This can be customised to impact a particular issue type as well.

Please let me know if you need guidance on the Automation rule.

Kindly accept the answer if this helps.

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2021

Hi @Gaurav 

 Thanks for the quick reply. We have JSU, JMWE and Script runner. Can we accomplish with those addons ?

Gaurav
Community Champion
November 17, 2021

Hello @Lakshmi CH 

Yes, these plugins can help you to accomplish this. Kindly accept the answer if this helps.

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2021

The below code is working as expected. Assign the ticket to particular user based on single selection field value.

 

-------------------------------------------------

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("Department List")
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 "Technology":
log.debug "Getting user for Desktop category."
userToReassign = userManager.getUserByKey("abc@abc.com")
break
case "Marketing/Sales":
log.debug "Getting user for Network category."
userToReassign = userManager.getUserByKey("xyz@abc.com")
break
}
log.debug "Setting user to ${userToReassign}."
issue.setAssignee(userToReassign)

-----------------------------------------------

Suggest an answer

Log in or Sign up to answer