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
4,370,157
Community Members
 
Community Events
168
Community Groups

Unassign inactive users with a script or automation

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

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

Atlassian Community Events