Set Assignee basing on other custom field is not working correctly


I am using behaviours plugin to set assignee during editing, here is my code:

FormField ass = getFieldById("assignee")
FormField formCurrent = getFieldById(getFieldChanged())
currentValue = formCurrent.getValue()
 if(null != currentValue){
      System.out.println("set admin ");
 }else {
     System.out.println("set cc5 ");


My problem is: this script is only executed once, for a instance, when i click edit, script identify my field value is null, then set assignee as "cc5", but after i change my filed value, script never be triggered again.

Meanwhile, "description" , " summary" are modified automatically and dynamically basing on my field value i changed.


Why this problem is happening on assignee field only?

JIRA: 6.3.11

Script runner plugin: 3.0.7

1 answer

This widget could not be displayed.

Hi Ma Hao,

Instead of behaviour script you can use a post function and apply it on the transition.

we can set assignee depends upon user picker custom field.

i have used this script for JIRA 6.3.11

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.user.util.UserUtil;
import com.atlassian.jira.user.ApplicationUsers.*;
import com.atlassian.jira.user.util.UserUtil;
import com.atlassian.jira.issue.index.IssueIndexManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.jira.user.ApplicationUsers;
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
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.DefaultUserManager
import com.atlassian.crowd.embedded.api.User



ComponentManager componentManager = ComponentManager.getInstance()
IssueManager issueManager = ComponentAccessor.getIssueManager()

//MutableIssue myIssue = issueManager.getIssueObject("PP-1")

MutableIssue myIssue = issue
Issue issue = issue;
log.error("----MY ISSUE KEY IS------"+myIssue)

CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
/*def user_name = customFieldManager.getCustomFieldObjectByName("Line Manager");
def user1=myIssue.getCustomFieldValue(user_name);
log.error("----------- USer Name Is-------"+user1)

def cfQAVerifier = customFieldManager.getCustomFieldObjectByName("Line Manager");

String us =myIssue.getCustomFieldValue(cfQAVerifier).name;
log.error("-------- User name is--------"+us);
log.error("----------Assignee Set----"+myIssue.setAssigneeId(us));

//UserManager userManager = UserManager.getInstance();
User ud=ComponentManager.getInstance().getUserUtil().getUser(us)
log.error("--------- USER NAME IS ------"+ud)


please used this and let me know wheather its working or not





Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

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

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

716 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