Loading ...

list of user ids? | Communifire Support

Communifire Support

Leave Space :

Are you sure you want to leave this space?

Join this space:

Join this space?

Add a new tab

Add a hyperlink to the space navigation. You can link to internal or external web pages. Enter the Tab name and Tab URL. Upload or choose an icon. Then click Save.

The name that will appear in the space navigation.
The url can point to an internal or external web page.
Login to follow, share, and participate in this space.
Don’t have a support community login?Create your account now
Posted in: Features and Functionality

list of user ids?

Subscribe to RSS
  • arester

    Is there a simple way to generate and download a list of Communifire user ids from a site? Thanks!

  • Foster

    Hi Aaron,

    You can use the REST API: Search Users to get a list of all users this way. Their User ID will be included in the returned values.

    I hope this helps,
    Foster

  • arester

    As far as I can tell, the Communifire user id (by which I mean the number) is *not* included in the user data that can be downloaded from Manage People...

  • Foster
    Answered

    Hi Aaron,

    My apologies, I was mistaken. User ID's are not included in the downloaded CSV.

    The REST API is the simplest way to retrieve a list of all user ID's. If you would like to not use the REST API functionality, to get a list of just user ID's you can create a pagebuilder page in Communifire to list the ID's. 

    First create a Page Builder Templates Select create new template and select People as the widget type. Add the following into the editor. 

     

            <ul>
            {{#each Contents}}
            <li>   
            {{UserID}}
            </li>                                                     
            {{/each}}
            </ul>

    Click Save Template

    Now go to the PageBuilder page, add a new page, and select the people widget. Click the gear icon on the widget, click edit properties. Set the list items to a number higher than your total user count. Next, go to the Template Tab select the template you just created. Save the widget, and click publish changes. Click Go to page to go to your new pagebuilder page with a list of all ID's. 

    If you would like, you can use the widget specific token menu to add other variables to the template if they need to, such as username, first and last name, etc.

  • raghav_khunger

    Hi Aaron,

    Extending what  Foster Clark mentioned, here is an example to download userids as CSV

    you could have this template:

     

    <a href="#" class="export">Export User IDs</a>
    <div id="dvData" style="display:none">
      <table id="myTable">
        {{#each Contents}}
        <tr>
          <td>{{UserID}}</td>
        </tr>
        {{/each}}
      </table>
    </div>
    <script>
    $(document).ready(function() {
    
    function sortTable(table, order) {
        var asc   = order === 'asc';
    
        table.find('tr').sort(function(a, b) {
            if (asc) {
                return $('td:first', a).text().localeCompare($('td:first', b).text(), undefined, {'numeric': true});
      
            } else {
                return $('td:first', b).text().localeCompare($('td:first', a).text(), undefined, {'numeric': true});
            }
        }).appendTo('#myTable');
    }
    
      function exportTableToCSV($table, filename) {
    
        var $rows = $table.find('tr:has(td)'),
    
          // Temporary delimiter characters unlikely to be typed by keyboard
          // This is to avoid accidentally splitting the actual contents
          tmpColDelim = String.fromCharCode(11), // vertical tab character
          tmpRowDelim = String.fromCharCode(0), // null character
    
          // actual delimiter characters for CSV format
          colDelim = '","',
          rowDelim = '"\r\n"',
    
          // Grab text from table into CSV formatted string
          csv = '"' + $rows.map(function(i, row) {
            var $row = $(row),
              $cols = $row.find('td');
    
            return $cols.map(function(j, col) {
              var $col = $(col),
                text = $col.text();
    
              return text.replace(/"/g, '""'); // escape double quotes
    
            }).get().join(tmpColDelim);
    
          }).get().join(tmpRowDelim)
          .split(tmpRowDelim).join(rowDelim)
          .split(tmpColDelim).join(colDelim) + '"';
    
        // Deliberate 'false', see comment below
        if (false && window.navigator.msSaveBlob) {
    
          var blob = new Blob([decodeURIComponent(csv)], {
            type: 'text/csv;charset=utf8'
          });
    
          // Crashes in IE 10, IE 11 and Microsoft Edge
          // See MS Edge Issue #10396033
          // Hence, the deliberate 'false'
          // This is here just for completeness
          // Remove the 'false' at your own risk
          window.navigator.msSaveBlob(blob, filename);
    
        } else if (window.Blob && window.URL) {
          // HTML5 Blob        
          var blob = new Blob([csv], {
            type: 'text/csv;charset=utf-8'
          });
          var csvUrl = URL.createObjectURL(blob);
    
          $(this)
            .attr({
              'download': filename,
              'href': csvUrl
            });
        } else {
          // Data URI
          var csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
    
          $(this)
            .attr({
              'download': filename,
              'href': csvData,
              'target': '_blank'
            });
        }
      }
    
      // This must be a hyperlink
      $(".export").on('click', function(event) {
          
        sortTable($('#myTable'), 'asc');
       
        // CSV
        var args = [$('#dvData>table'), 'export.csv'];
    
        exportTableToCSV.apply(this, args);
    
      });
    });
    </script>

    You can add a People widget using that template selected:

    It will render like this:

    On clicking that link you will be able to download the CSV which will look like this:

    Thanks,
    Raghav

Page 1 of 1 (5 items)