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 Sign up to answer
Community showcase
Posted Tuesday in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

26 views 0 2
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