Here at Member.buzz we wanted to create multiple assignees for a JIRA issue where each assignee was responsible for a different part of the issue's workflow.

For example, let's say you have a technical task with the following steps:

In this scenario, we would have to have two people involved, an Engineer should be responsible for most of the work but when the issue is in Testing we would want a Tester to be assigned.

Since JIRA allows us a single assignee for a given issue, we'll use the ScriptRunner plugin by Adativist to create a listener that will modify the assignee whenever a change occurs in the issue, setting the assignee to the correct user.

Create Custom Fields

First, make sure that you create two custom User Picker fields to contain the additional assignees.

Create Listener
Navigate to the Scriptrunner section of your JIRA's administration section and select listeners.configuration and create a listener for all issue events (that way it will update the assignee on workflow transition and if you change any of the relevant fields).

Write Script
Finally, insert the following script (created with help from Adaptivist's awesome support):

    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.event.type.EventDispatchOption
    import com.atlassian.jira.issue.Issue
    import com.atlassian.jira.issue.CustomFieldManager
    import com.atlassian.jira.issue.MutableIssue
    import com.atlassian.jira.issue.comments.CommentManager
    import com.atlassian.jira.issue.fields.CustomField
    import com.atlassian.jira.util.ImportUtils
    import com.atlassian.jira.user.util.UserManager
    import com.atlassian.crowd.embedded.api.User
    import com.atlassian.jira.user.ApplicationUser

    def issue = event.issue as MutableIssue;
    def customFieldManager = ComponentAccessor.customFieldManager;

    ApplicationUser fieldValue = null;

    if (issue.status.name == "Testing")
    {
    fieldValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(issue).find { it.name == "Tester" }) as ApplicationUser;
    }
    else
    {
    fieldValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(issue).find { it.name == "Engineer" }) as ApplicationUser
    }

    if (fieldValue != null)
    {
    if (issue.assignee)
    {
    if (fieldValue.getUsername() == issue.assignee.getUsername())
    {
    return;
    }
    }

    def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
    issue.setAssignee(fieldValue);
    ComponentAccessor.issueManager.updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false);
    }⁠

Using this script as a starting point, you can create all sorts of cool workflows!

Comments

To add a comment, please login or register.

Related

C-Level Security: When your team uses military analogies, are they using the wrong narrative?
For years, I have bristled when people would use medieval military descriptions in an attempt to convey concepts within the Network Security business. Bastions, Firewalls, Moats, Drawbridges, Countermeasures; all of these descriptions give way to a more accurate and detailed explanation of what was really taking place.
Using a Lenovo P51 Laptop with an Airplane Power Supply
The Lenovo P51 Laptop comes with a huge 170 watt Power Supply. However, airplane power supplies provide a maximum of somewhere between 75-100 watts. If you plugin a power supply requiring more watts, the circuit breaker will short out and the power will stop flowing.
Turning Atlassian JIRA into a CRM
Here at Member.buzz, we use Atlassian JIRA to track our features, bugs, and incoming requests from users through our Support Site. So when it came to choosing a CRM, we wanted to find one that integrated nicely with the rest of our infrastructure.Our first thought was to try out some of the existing JIRA CRM plugins. Here are the ones we tried out:CRM for JIRAAtlas CRMKanoah CRMAlthough there were definitely some interesting features among these options, there was nothing substantial enough to make us want to choose a specific one. We wanted something simple, yet well-integrated into what we already had
Setup Point-to-Site VPN with Ubiquiti EdgeRouter
Learn how to setup a VPN with your Ubiquiti EdgeRouter.