Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unassign inactive users with a script or automation

Baris Sehitoglu
Contributor
November 8, 2021

I noticed that there are still a few tickets that are now assigned to employees who have since left the company.

 

We would like to have an automation for this which, say, checks every 24 hours whether the assignee of a ticket (all types) in our project is inactive and in this case removes the assignee again, the ticket should remain in the assigned team

Is this possible and how ?

thanks 

 

2 answers

0 votes
Shauna
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 29, 2022

This case be done for free with Jira Automation

 

Trigger: On Schedule (Set cron up how you would like)

# We want to look in a specific project. Check that the resolution is empty so we only include current cases in our search and assignee is 'in' the inactiveUsers() function which is pulling from the users database of jira
Trigger JQL: project = {INSERT YOUR PROJECT} AND resolution is EMPTY AND assignee in inactiveUsers()

Then: Assign Issue {INSERT WHO EVER YOU WOULD LIKE TO ASSIGN THESE CASES TO}

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2021
Yes this is possible with scriprunner.

You can use either an escalation service job or a custom job.

With the escalation service, you can specify the JQL to find those tickets right in the job definition form. For example:

assignee in inactiveUsers() and resolution is empty

The trick with the escalation job is that you'll have to leave the Action blank which means don't perform any workflow actions.

And since you are not performing any transition, you can't use the examples that leverage the issueInputParameters variable that's provided in the Additional Issue Actions script.

But you can still write your own script that will call the issueService and set the Assignee to "unassigned".

Maybe something like this:

import com.atlassian.jira.component.ComponentAccessor

def issueService = ComponentAccessor.issueService
def validationResult = issueService.validateAssign(currentUser, issue.id, null)
if(validationResult.isValid()){
issueService.assign(currentUser, validationResult)
} else {
log.error validationResult.errorCollection*.errorMessages.join('\n')
}

 I can't test it because my system doesn't allow issues to be unassigned. So I'm a little unsure about the "null" part.

Suggest an answer

Log in or Sign up to answer