Auto assign incoming issues based on conditions

I'm working on a workflow with JIRA Service Desk for our onboarding process. I'd like for the issue to automatically assign to one team if a particular custom field is selected and to a different team if it is not.  

I've configured triggers from an Open status to an In Progress status that effectively do this but do not do it automatically from issue creation (the assignments are correct though if you take the issue and click the appropriate transition button), but I cannot seem to have multiple transitions from the Create Issue status to allow for the conditional element.  

Is there something I'm missing here?

2 answers

I think the right place/method to do that is a custom script post-function on the create transition.  Something like:

import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
 
ComponentManager componentManager = ComponentManager.getInstance();
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
CustomField yourCustomField = customFieldManager.getCustomFieldObjectByName("Your Custom Field");
 
editableIssue = (MutableIssue)issue;
 
if (issue.getCustomFieldValue(yourCustomField) == "Value 1") {
	editableIssue.setAssignee();
}

setAssignee() takes an ApplicationUser; it may be easier to use setAssigneeId() if you can figure out what that is, as it just takes a string.  I don't have a sample handy for building an ApplicationUser from a userID.

A more non-programming solution would be to use the conditioning support in the Update issues post function from Update on Transition for JIRA. See How to update issues after initial issue create.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,317 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot