JSM Wrap-up August - Atlassians virtual agent, User security & more
Exploring the latest enhancements in Jira Service Management August proved to be a bustling yet productive month for Atlassian, particularly on the...
3 min read
Deniz
:
Jun 19, 2023 10:53:54 AM
Managing user licenses and determining the number of active agents in Jira Service Management (JSM) is crucial when organizations transition to the Atlassian Cloud or Data Center platforms. As subscription costs are based on the number of users, accurately assessing the user count becomes a significant challenge. To address this issue, we have developed a Groovy script that leverages Adaptavist Scriptrunner for Jira to determine the number of active JSM agents in your organization.
The given Groovy script leverages Jira's official Java API to achieve the same outcome as an SQL statement. The code executes the following actions:
The Groovy script below, developed to be used with Adaptavist Scriptrunner for Jira, uses Jira's official Java API to answer this question. Additionally, it gives the same function as SQL statement.
SELECT DISTINCT u.lower_user_name
FROM cwd_user u
JOIN cwd_membership m ON u.id = m.child_user_id
JOIN cwd_group g ON m.parent_id = g.id
JOIN app_user au ON u.lower_user_name = au.user_key
JOIN changegroup cg ON au.user_key = cg.author
JOIN jiraissue ji ON cg.issueid = ji.id
JOIN project p ON ji.project = p.id
JOIN nodeassociation na ON p.id = na.source_node_id
WHERE u.active = 'T'
AND g.lower_group_name = 'jira-servicedesk-users'
AND na.sink_node_entity = 'ProjectType'
AND na.sink_node_id = (SELECT id FROM projecttype WHERE "key"='service_desk
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
def groupManager = ComponentAccessor.getGroupManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def projectManager = ComponentAccessor.getProjectManager()
// Holen Sie sich alle aktiven Benutzer in der Gruppe 'jira-servicedesk-users'
def users = ComponentAccessor.getUserManager().getUsersInGroup('jira-servicedesk-users').findAll { it.isActive() }
// Holen Sie sich alle JSM-Projekte
def jsmProjects = projectManager.getProjectObjects().findAll { it.projectTypeKey.key == 'service_desk' }
// Ergebnis
def result = []
users.each { user ->
def userHasEditedJSMIssue = jsmProjects.any { project ->
def issuesInProject = ComponentAccessor.getIssueManager().getIssueObjects(ComponentAccessor.getIssueManager().getIssueIdsForProject(project.id))
issuesInProject.any { issue ->
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "*")
changeItems.any { ChangeItemBean changeItemBean ->
changeItemBean.getUserKey() == user.key
}
}
}
if (userHasEditedJSMIssue) {
result << user.name
}
}
return result
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
def groupManager = ComponentAccessor.getGroupManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def projectManager = ComponentAccessor.getProjectManager()
// Holen Sie sich alle aktiven Benutzer in der Gruppe 'jira-servicedesk-users'
def users = ComponentAccessor.getUserManager().getUsersInGroup('jira-servicedesk-users').findAll { it.isActive() }
// Holen Sie sich alle JSM-Projekte
def jsmProjects = projectManager.getProjectObjects().findAll { it.projectTypeKey.key == 'service_desk' }
// Zeitpunkt vor 3 Monaten
def threeMonthsAgo = new Date() - 3.months
// Ergebnis
def result = []
users.each { user ->
def userHasEditedJSMIssue = jsmProjects.any { project ->
def issuesInProject = ComponentAccessor.getIssueManager().getIssueObjects(ComponentAccessor.getIssueManager().getIssueIdsForProject(project.id))
issuesInProject.any { issue ->
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "*")
changeItems.any { ChangeItemBean changeItemBean ->
changeItemBean.getUserKey() == user.key && issue.getCreated().after(threeMonthsAgo)
}
}
}
if (userHasEditedJSMIssue) {
result << user.name
}
}
return result
While the script is incredibly useful, it's important to keep the following points in mind:
Determining the number of active JSM agents is a critical task when managing user licenses in Jira Service Management. Our provided Groovy script offers a practical solution to this challenge, simplifying user management and facilitating cost calculations for cloud or data center subscriptions. However, exercise caution when running the script and always test it in a safe environment before deploying it in your production setup.
If you have any questions or require further customizations, please don't hesitate to reach out to us. We're here to help you make the most of Jira Service Management and optimize your user management processes.
More about Jira Service Management and our licenses
Jira Service Management trainings
Atlassian Enterprise License Agreement (ELA)
The Future of ITSM with Atlassian
Exploring the latest enhancements in Jira Service Management August proved to be a bustling yet productive month for Atlassian, particularly on the...
New Jira Service Management features and updates June was definitely a busy month for Atlassian on Jira Service Management front. We have been...
Exploring the Latest Enhancements in Jira Service Management Atlassian is on a roll, introducing some exciting updates to Jira Service Management...