Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to commit changes unassigning issue in groovy script


We need a groovy script that clears Assingee field to Unassigned.

This script will be triggered from script runner, only in certain conditions.

My code:


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

import com.atlassian.crowd.embedded.api.User


MutableIssue issue = issue


log.error("Assignee: " + issue.getAssigneeId())


the log is printing null, which is correct, but when consulting the issue it is istill assigned.

what i'm doing wrong?

Thx in advance!!

1 answer

0 votes

Where is this being run from?

If it's run from a PostFunction, the change may be missing because of the order of the post functions. Be sure to place it before "update change history and story the issue".

If this is in a listener or other script, then you need to perform several steps yourself if you want to replicate the normal behavior.

  1. call updateIssue() method from IssueManager to store the issue in the db
  2. call createChangeGroup() method from ChangeLogUtil to create the change history
  3. call reIndex(issue) method from IssueIndexingService to update the index and have the new values available for searching.

There are several examples in the community for how to use all those

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

196 views 1 6
Read article

Atlassian Community Events