Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to commit changes unassigning issue in groovy script

Hi,

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

issue.setAssignee(null)

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
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

94 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you