Ability to download the list of licensed users from the UI

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: User - Management
    • None
    • 2

      Currently, we can list users who are being counted towards the license. However, we don't have a download button on the UI that would enable users to download the whole list easily.

      Workaround

      For now, users can use the KB article to get the list of active users who count toward the license.

      Script alternative: You can use the script below on your browser to download the list of users directly. This script also works for nested groups.

      How to use the script:

      1. Open the Webpage: Confluence -> Users -> List Users screen
      2. Open the browser's Developer Tools (usually F12 or right-click → "Inspect").
      3. Go to the Console tab.
      4. Paste the below code
      5. Replace your BASEURL in line 2 of the code
      6. and press Enter.
      7. A CSV file named all_users.csv will be downloaded to your downloads folder.

      Script:

      (async function fetchPaginatedTablesCleaned() {
          const baseUrl = "<<BASEURL>>"
          const resultsPerPage = 500;
      
          const userSearchUrl = baseUrl + "/admin/users/dosearchusers.action?showUnlicensedUsers=false&searchTerm=*&usernameTerm=&fullnameTerm=&emailTerm=&resultsPerPage=" + resultsPerPage + "&startIndex=";
          
          let startIndex = 0;
          let allRows = [];
          let hasMoreData = true;
          
          while (hasMoreData) {
              const url = userSearchUrl + startIndex;
              console.log("Fetching:", url);
              const response = await fetch(url, { credentials: 'include' });
              const html = await response.text();
              const parser = new DOMParser();
              const doc = parser.parseFromString(html, "text/html");
              const table = doc.querySelector("table");
              if (!table || table.rows.length === 0) {
                  console.log("No table or empty table found at index", startIndex);
                  break;
              }
              const rows = Array.from(table.rows).map(row =>
                  Array.from(row.cells).map(cell =>
                      `"${cell.innerText.replace(/\s+/g, ' ').trim().replace(/"/g, '""')}"`
                  ).join(",")
              );
              allRows.push(...rows);
              // Stop if less than expected results returned (likely last page)
              if (table.rows.length < resultsPerPage + 1) { // +1 for header
                  hasMoreData = false;
              } else {
                  startIndex += resultsPerPage;
              }
          }
          // Remove duplicate headers
          const headers = allRows[0];
          const bodyRows = allRows.slice(1).filter(row => row !== headers);
          const finalCsv = [headers, ...bodyRows].join("\r\n");
          const blob = new Blob([finalCsv], { type: "text/csv;charset=utf-8;" });
          const url = URL.createObjectURL(blob);
          const link = document.createElement("a");
          link.href = url;
          link.download = "all_users.csv";
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
          console.log(":white_check_mark: Done! Downloaded cleaned CSV from all paginated pages.");
      })();

       

            Assignee:
            Unassigned
            Reporter:
            Hima Bindu Ramisetty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: