Set assignee field based on a condition

How am I able to set the assignee field of an issue based on a condition when a transaction is fired?

What I want to achieve is the following "condition":

projectRoleUsers = project.getUsersInRole("Rolename");
if(currentUser() in projectRoleUsers) {
   newAssignee = "unassigned";
else {
  newAssignee = projectRoleUsers.first();
issue.assignee = newAssignee;

I tried to achieve this by doing the following:

  • Assign the issue to the default user from the Rolename role. 
  • The value of field Assignee of the current issue will be set to null (replacing existing values).
    • With condition: return (currentValue == currentUser);


This however doesn't work as I want it to. Basically the Role can only be filled with one user (or empty). On this transition the assignee always needs to be set to that user unless the person executing the transition is the same user.

Hopefully someone can tell me how to set this up correctly smile

2 answers

  1. Is it full code or just an idea to do
  2. You do not store changes into database, since no update
  3. I do not understand an algorithm to get assignee. 
    1. What does it mean default user from project role. It is not defined value, because project role if filled by users and groups. We can speak that current user is into project role. 
    2. If you want to get unassugned issue you should use issue.assignee = null


  1. This is just an idea of what I want to achieve
  2. I had set these actions for the transition in my workflow, purging field or filling it with the user from the specified role works perfectly, however I want to add another condition smile
  3. With the default user for the project role I mean the user who we have assigned for the role. This is only one user, not a group or multiple users.

Here a quick view of the situation how it should be;

  • Each project has one specific user assigned for "Code review" (Role for the project).
  • Once a issue goes from Development to "Code review" we want this issue to be assigned automatically to the user who belongs to the "Code review" role for that specific project, unless that person is the one doing the transition.

The following works perfectly fine for automatically assigning the right user to the issue:

From this point all I need is to check whether that person is the "currentUser()", if so the assignee should be assigned to "unassigned".

Hey Paul,

As per the above description, i have a smillar question.

suppose i have a 'if condition' how we are going to right that condition for 'Code Review'


if ( Customfiedtype = Desktop||Laptop )  Assignee = code review

Please help me out on this..



This code will unassign an issue when curUser = assignee:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser

ApplicationUser curUser = ComponentAccessor.jiraAuthenticationContext.getUser();

if(curUser == issue.getAssignee())

ComponentAccessor.getIssueManager().updateIssue(curUser, issue, EventDispatchOption, false)

Use it for script postfunction. Hope it will help.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


125 views 0 3
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