Can I report based on user properties?

Samuel Gatica _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2019

Can I have a report where i can see information of all users which contain user properties?

I found this post: https://community.atlassian.com/t5/Answers-Developer-Questions/Can-I-report-based-on-user-properties/qaq-p/545768 

But this groovy code for ScriptRunner, but is not working on Jira Cloud

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
 
UserUtil userUtil = ComponentAccessor.getUserUtil()
 
def result = ""
 
// Get details for each user
userUtil.getUsers().findAll{it.isActive()}.each{ u ->
    result += u.name + "," + u.displayName + "," + u.emailAddress + "," + u.properties + "<br/>"
}
 
// Use these three lines for all users rather than all active users
//userUtil.getUsers().findAll().each{ u ->
//    result += u.name + "," + u.displayName + "," + u.emailAddress  + "," + u.properties + "<br/>"
//}
 
// Return the results out to the script console in a comma seperated format which can be taken and pasted into another tool such as excel
def header ="Username" +"," + "Full Name" +"," + "Email" +"," + "User Properties Array"
def formatteresult = header +"<br/>" + result
 
return formatteresult

 

Here is error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 9: expecting '}', found '-' @ line 9, column 52.
indAll{it.isActive()}.each{ u ->

 

Thanks in advance

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 29, 2019

Hi Sam,

Thank you for your question.

Thank you for your question.

I can confirm that the reason that your code above will not work inside of ScriptRunner for Jira Cloud is due to the fact the code you have provided is fro ScriptRunner for Jira Server and this will not work as Atlassian only provide a rest API in Jira Cloud and do not provide a Java API in the cloud like they do in Jira Server.

You can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.

We would recommend reviewing the documentation for ScriptRunner for Jira Cloud which is located here along with the Jira Cloud Rest API Documentation in order to see how the REST API's work in Jira cloud.

I can also confirm that to report on users you would need to use the Get All users rest API but can confirm that Atlassian do not permit apps to use this resource meaning that you will be unable to use ScriptRunner for Jira Cloud to return all users and to report on them.

However I can confirm that you can get a list of all users by navigating to the URL of <JiraBaseURL>/rest/api/3/users/search in your web browser when logged in as a site admin user and you could take the information used from this page and use it for reporting purposes.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer