Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

Find Inactive Users within a Date Range

I'm trying to get the number of users who became Inactive within the past year.

I followed this script and added a table to print the list for me, but the problem is the script still pulls up all Inactive users. Meaning I'm seeing users last login since 2015 when I just want to see inactive users whose last login was within 2022.

import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.crowd.embedded.api.CrowdService
import groovy.xml.MarkupBuilder

import java.time.LocalDateTime
import java.time.Instant
import java.time.ZoneId

def crowdService = ComponentAccessor.getComponent(CrowdService)

def result ="<table class='aui'"

// review in the last year
def numOfDays = 365
def dateLimit =

// Search all inactive users
UserSearchParams.Builder paramBuilder = UserSearchParams.builder()

def jiraServiceContext = new JiraServiceContextImpl(ComponentAccessor.jiraAuthenticationContext.loggedInUser)
def allInactiveUsers = ComponentAccessor.getComponent(UserSearchService).findUsers(jiraServiceContext, '',

// Users which last activity is after limit date
def inactivePastYear = allInactiveUsers.findAll { user ->
def userWithAtributes = crowdService.getUserWithAttributes(user.username)
def lastLoginMillis = userWithAtributes.getValue('login.lastLoginMillis')

if (lastLoginMillis?.number) {
def lastLogin = Instant.ofEpochMilli(Long.parseLong(lastLoginMillis)).atZone(ZoneId.systemDefault()).toLocalDateTime()
if (lastLogin.isAfter(dateLimit)) {
def sb = new StringBuffer()

result +="</table>"
return result

Is there a way, maybe, I can have the script check between 2 dates? Between start of Year to end of Year?

1 answer

Hi @Diana Gorv

There is another example code for this in the Adaptavist Library. This example uses the Escalation Service.

Since you only want the list of inactive users, you will need to filter the code a bit.

Give it a try and see how it goes.

Thank you and Kind regards,

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events