Getting a Group List for an Owner

Users can get a list of groups that they are the owner of.

The following sample code shows how to get a list of groups that the current user is the owner of.

  • // Get the currently logged-in user.
    var user = KiiUser.getCurrentUser();
    
    // Get a list of groups owned by the current user.
    user.ownerOfGroups({
      success: function(theUser, groupList) {
        for(var i = 0; i < groupList.length; i++) {
          var g = groupList[i];
          // Do something.
        }
      },
      failure: function(theUser, errorString) {
        // Handle the error.
      }
    });
  • // Get the currently logged-in user.
    var user = KiiUser.getCurrentUser();
    
    // Get a list of groups owned by the current user.
    user.ownerOfGroups().then(
      function(params) {
        var theUser = params[0];
        var groupList = params[1];
        for(var i = 0; i < groupList.length; i++) {
          var g = groupList[i];
          // Do something.
        }
      }
    ).catch(
      function(error) {
        var theUser = error.target;
        var errorString = error.message;
        // Handle the error.
      }
    );