Groovy post script to set assignee based on cutom field

I am new to this and I have looked at several examples I have tried to tweak one that I think will work for what I need done but not sure if I did it right.

We have a custom filed called Work Unit (customfiled ID of 13270) It has two options Outreach & Online Education (Option ID 13880) and Undergraduate Admissions (Option ID 13881)

What I want is when a ticket comes in with the Work Unit set to Outreach & Online Education I want the Assignee to be set as user talismasupport, if it comes in as Undergraduate Admissions I want the Assignee to be uaosupport.

 

This is what I have but I don't think it is right.

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
 
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
IssueManager issueManager = componentManager.getIssueManager()
 
CustomField srcField = customFieldManager.getCustomFieldObjects(customfiled_13270).find {it.name == "CustomField"}
 
cfwt = issue.getCustomFieldValue(customfiled_13270)
 
 
if (cfwt == "Outreach & Online Education"){
            issue.setAssignee(ComponentManager.instance.userUtil.getUserObject('talismasupport'))
            }
             
else if (cfwt == "Undergraduate Admissions"){
            issue.setAssignee(ComponentManager.instance.userUtil.getUserObject('uaosupport'))
            }


1 answer

This widget could not be displayed.

Or can this be done with JQL?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

146 views 2 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you