Example scripts
To homepage
Jira

Retrieve List of Inactive Users
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.5 - 8.22)

ScriptRunner For Jira (6.45.0)
Language |
groovy
import com.atlassian.jira.bc.user.search.UserSearchParams
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.component.ComponentAccessor
def userSearchService = ComponentAccessor.getComponent(UserSearchService)
final def limitValue = '<SPECIFY_VALUE>'
//Build a search with 100,000 results where users are inactive
def userSearchBuilder = new UserSearchParams.Builder(limitValue)
def userSearchParams = userSearchBuilder.allowEmptyQuery(true)
.includeActive(false)
.includeInactive(true)
.limitResults(limitValue)
.build()
//Retrieve immutableList of Inactive Users
def inactiveUsers = userSearchService.findUsers('', userSearchParams)
//You can convert immutableList inactiveUsers, to a List<String> with below
//which is useful for method like ProjectRoleService.removeActorsFromProjectRole()
def usersToRemove = [] as List<String>
inactiveUsers.each {
usersToRemove.add(it.key.toString())
}
Having an issue with this script?
Report it here