Import User within groups - REST API - Data import

Hi,

Is there someone or somewhere where I can find how to make a user management report?

It’s about creating a report about user and group management in Jira.

The solution will probably be to import the data with API:

Following up with JavaScript that would each group extract the users:

JavaScript:

var resultArray = [];

// Ensure doc.groupId exists before proceeding
if (doc.groupId) {
    // Log account ID for debugging
    console.log("Processing account ID: " + doc.groupId);

    // Fetch users for the group
    var result = getDocument(
        "/rest/api/3/group/member?groupId=" + doc.groupId,
        { ignoreErrors: [404] }
    );

    // Log the API response for debugging
    console.log("API response: " + JSON.stringify(result));

    // Process users if the API returns data
    if (result && result.values && result.values.length > 0) {
        for (var i = 0; i < result.values.length; i++) {
            var user = result.values[i];
            console.log("Processing user: " + JSON.stringify(user));
            if (user && user.emailAddress) {
                resultArray.push({
                    groupName: doc.name || "Unknown",
                    userEmail: user.emailAddress
                });
            }
        }
    }
} else {
    console.log("Skipping document without groupId.");
}

// Return the structured array
data = resultArray;
return data;

The problem lies here: I am still new and don’t know how I would make a dimension that would have a property that would show multiple users upon expanding the group.

I may be missing something. I would appreciate any help :slight_smile:

Hi @Patrik_Stoural,

Users can be part of multiple groups. In such a case, I recommend importing the “groupName” and “userEmail” columns as separate dimensions, for example, Group and User. Add a numeric measure to tie the results together. If you don’t have a numeric measure in your data source, you can add one in the data mapping - Data mapping.

The data mapping could look similar to the one below:


Add both dimensions to the report rows and filter the report rows by your numeric measure to see only relevant combinations - Create reports. See an example below:

Best,
Roberts // support@eazybi.com