Assign an issue based on Radio Button Selection (Groovy)

Hi,

I want to create a Groovy script that will automatically assigne an issue to a specific person depending on the value selected in a custom field (Radio Button type)


ex:

if Radio Button Option 1 is selected upon jira ticket creation, it will assign automatically to Mike
if Radio Button Option 2 is selected upon jira ticket creation, it will assign automatically to Paul
if Radio Button Option 3 is selected upon jira ticket creation, it will assign automatically to Robert

etc...

I'm a beginner in groovy, can someone give me a basic code that will help me to acheive that?

thnx in advance!

1 answer

1 accepted

4 votes
Henning Tietgens Community Champion Dec 27, 2012

I assume you want to do this while performing a workflow transition. In this case you have to create a Script Post Function.

Within this Script Post Function you can use a switch statement (http://groovy.codehaus.org/Logical+Branching) to test the value of the Radio Button custom field and change the assigne to the desired user.

To get the value of the custom field:

import com.atlassian.jira.ComponentManager
def cfManager = ComponentManager.instance.customFieldManager
def cfRadioButton = cfManager.getCustomFieldObjects(issue).find {it.name == 'Name of RadioButton CF'}
String cfValue = issue.getCustomFieldValue(cfRadioButton).getValue()

To get the user needed and change the assignee:

issue.setAssignee(ComponentManager.instance.userUtil.getUserObject('userlogin'))

You should add appropiate error checking to your code...

Henning

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

158 views 0 4
Read article

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