Hello All,
I am looking for a solution to send a custom notification to members in a Jira project. The function should check for users(already added in the project roles) who have not accessed the project "ABC" for the last 90 days. A custom notification should be send to these users.
I am currently using Jira Datacenter 8.20.30. I do have scriptrunner plugin but not the Automation for Jira plugin.
Any help will be much appreicated. Thank you.
Schedule Script Execution: Schedule the script to run at regular intervals (e.g., daily) using ScriptRunner's built-in scheduler
Change the script based on your requirement also Make sure to replace the placeholder logic in the isInactive
function with your actual implementation to check if a user is inactive based on their last login time.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.bc.project.ProjectService
import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.bc.projectroles.ProjectRoleActorService
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.web.bean.PagerFilter
def projectKey = "ABC"
def projectRoleName = "Developers"
def userManager = ComponentAccessor.getUserManager()
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def projectService = ComponentAccessor.getComponent(ProjectService)
def projectRoleService = ComponentAccessor.getComponent(ProjectRoleService)
def projectRoleActorService = ComponentAccessor.getComponent(ProjectRoleActorService)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def project = projectService.getProjectByKey(userManager.getUserByName("admin"), projectKey).getProject()
def projectRole = projectRoleManager.getProjectRole(projectRoleName)
def projectRoleId = projectRole.id
def inactiveUsers = []
def usersInRole = projectRoleActorService.getUsersInProjectRole(projectRole, project)
usersInRole.each { ProjectRoleService.UserRoleActor actor ->
def user = actor.getDescriptor().getUser()
if (user && isInactive(user)) {
inactiveUsers << user
}
}
def isInactive(ApplicationUser user) {
// Example logic:
// def lastLogin = userManager.getLastLoginTime(user)
// return lastLogin && lastLogin.before(Date() - 90)
// Replace the above example logic with your actual implementation
return true // Placeholder logic
}
return inactiveUsers
Hi Sudarsana ,
Thank you for your help.
I have tried these script but getting error for
import com.atlassian.jira.bc.projectroles.ProjectRoleActorService library. It is showing unable to resolve class import com.atlassian.jira.bc.projectroles.ProjectRoleActorService
I'm using Jira Data Center 8.20.30 version. So is it supported for this version or is there any other option instead of this library?
Any help will be much appreciated. Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Team ,
Can you please provide any suggestions for the above comment. Actually I'm stuck here.
Any help will be much appreciated. Thank you.
Best Regards,
Richa Aware
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.