How to Set current assignee to "Unassigned" whenever group picker field is changed?

I have a group picker field called "Assigned Team." Whenever someone changes the group in the group picker to any group, how can I automatically set the Assignee back to "Unassigned"? Not sure how to do this in either a Behaviour or Script Listener? Thank you.

1 answer

You can go with Custom Listener and configure it to trigger on "Issue Update" event (or any events combination of your choosing):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager

def currentIssue = event.issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def groupField = customFieldManager.getCustomFieldObjectByName('Group Field');
def groupFieldValue = currentIssue.getCustomFieldValue(groupField);

if (groupFieldValue != null) {
 currentIssue.setAssignee(null);
}

Note that ScriptRunner inline script syntax checker can see an error in the line that sets assignee but script will work fine without errors.

Hey Ron,

 

I have a similar need but your response is not working. I pasted my code below. My situation is that I am using a global listener to clear the assignee field if a custom field changes. I know my change code works, cause I use it for changing priority based on the change. But I can't get the assignee to null out.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager

def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Assignment Group"}

def currentIssue = event.issue;

if(change)
{
currentIssue.setAssigneeId(null);
return true
}
else return false

 any help you could give would be much appreciated.

Thanks,

Jason

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 ...

2,801 views 11 18
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