ScriptRunner to clear all inactive assignees w/o updating issues

After noticing how ScriptRunner's built-in script to clean up resolutions doesn't count as activity on the issues it touches, I wondered if similar clean-up operations could be done from the script console. In this case, I'd like to find all issues that haven't been updated in x days, where the assignee is an inactive account, and then reset those issues to unassigned.

This is pretty easy to do with a bulk operation, but I'd like to avoid making a bunch of old tickets look suddenly active again if possible.

It's probably also simple from the database, but I try to work with a policy of not writing to that unless I absolutely HAVE to.

Thanks!

1 answer

1 accepted

1 votes

You will need to do the storing and indexing manually without going through any of the issue services or managers otherwise the history will change.

You can adapt the following code to prevent an entry being added in the history:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.util.ImportUtils

def indexManager = ComponentAccessor.getComponent(IssueIndexManager)

boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);

try {
    // do something to issue object and store
    issue.store()
}
finally {
    indexManager.reIndex(issue);
    ImportUtils.setIndexIssues(wasIndexing);
}

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,755 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