Tips on finding inactive users?

Tips on finding inactive users?

  
Anyone have any good tips for finding and deleting in bulk inactive users? I have a customer that's right near the user limit for their tier, and while I'd like them to upgrade, they'd rather do some housekeeping first. :-)
What do you mean by inactive?
  • Users explicitly inactivated (shown if you click the Inactive Users link in the /Users app).
  • Or users that don't login for a long time (e.g. one year).
For the 1st scenario, I'm not sure if inactive users count for licensing purposes (they can't login anyway)...

Nevertheless, these users are in the User entity, that you can reference from the (System) eSpace (it's already referenced by default when you create a new module). This way, you can build a query returning all your inactive users (you can filter for attributes Is_Active or Last_Login, depending on your goal above).

Once you have this list of users, you can delete them in bulk using the DeleteUser entity action inside a ForEach loop. This is where you may run into problems, since your application entities may be referencing some of these rows, and if they are using a Protect delete rule, the database will throw an error. So, you have to decide what to do on these cases (clear YourEntity.UserId? update it to a special "deleted" user? change the delete rule to Ignore?...).

By the way, if you're using multi-tenancy, you may want to double-click the User entity and select Show Tenant Identifier (Advanced tab), so it returns users from all tenants. And be careful not to delete useful but rarely used users, like the default Administrator.
Users that don't log in for a long time... 

I'll send my customer to this thread (more traffic for the community!) and see where we go from there. Obrigado!

Paulo Ramos wrote:
What do you mean by inactive?
  • Users explicitly inactivated (shown if you click the Inactive Users link in the /Users app).
  • Or users that don't login for a long time (e.g. one year).
For the 1st scenario, I'm not sure if inactive users count for licensing purposes (they can't login anyway)...

Nevertheless, these users are in the User entity, that you can reference from the (System) eSpace (it's already referenced by default when you create a new module). This way, you can build a query returning all your inactive users (you can filter for attributes Is_Active or Last_Login, depending on your goal above).

Once you have this list of users, you can delete them in bulk using the DeleteUser entity action inside a ForEach loop. This is where you may run into problems, since your application entities may be referencing some of these rows, and if they are using a Protect delete rule, the database will throw an error. So, you have to decide what to do on these cases (clear YourEntity.UserId? update it to a special "deleted" user? change the delete rule to Ignore?...).

By the way, if you're using multi-tenancy, you may want to double-click the User entity and select Show Tenant Identifier (Advanced tab), so it returns users from all tenants. And be careful not to delete useful but rarely used users, like the default Administrator.