2 Replies Latest reply on Aug 15, 2014 12:08 AM by michaelfr RSS
    michaelfr Creator

    Check if user is enabled


    I want to return a list of users, however I do not want to include the ones that are not enabled. How can I differentiate them?

    Thank you,


      • Check if user is enabled
        adam Creator

        Hi Michael,


        Unfortunately, there isn't an easy way to generate a list of only enabled


        . I've requested a couple


         from development that will


        make this much easier. For the time being, you'll need to get all of the


        , iterate through the resulting


         and use a REST call to get the


         as JSON. Of course, then you'll need to parse through the JSON to find the value for "enabled". If the value is true, you'll add it to another


         that you will return (or alternately, if it's false, you could remove disabled


         from your initial



        Here's the code:

        var users = Groups["Users"].GetGroupMembers(); // Get All Users

        var numberOfUsers = users.RowCount();

        var headers = new Object();

        headers.Accept = "application/json";

        var i = 0;

        while (i < numberOfUsers) {

          var user = Resources["ContentLoaderFunctions"].GetJSON({

            headers: headers,

            url: "http://localhost/Thingworx/Users/" + users[i].name,

            username: "Administrator",

            password: "admin",

            ignoreSSLErrors: true,

            withCookies: true,

            timeout: 30



          if (user.enabled == "false") {

            users.RemoveRow(i); // Remove Disabled User      

            numberOfUsers--; // Decrement Number of Users

          } else {

            i++; // No Users Removed



        result = users; // Return Final InfoTable

        • Check if user is enabled
          michaelfr Creator

          Thank you Adam! That was a huge help!