+ Start a Discussion
Rahul H 4Rahul H 4 

query inactive user record

I want to query in Salesforce database for an inactive user to check if he is owning any records or not?
I tried to query in Salesforce data loader but it only queries on one entity at a time. Also, the same behavior is shown for Reports wherein one entity gets queried at a time. 

Please advise further. Thanks

Hi Rahul,

Try this........,

Create a formula field of type Checkbox on the object and formula will be 'Owner.IsActive'. It returns true if Owner is Active otherwise false.
Then create a report on the object with this checkbox = false as filter.
This report will give you the number of records which are owned by inactive users.

Run a query in developer console which will give you the count of records which are owned by inactive users.
For Ex:
Select count() FROM Contact WHERE Owner.isActive = false

Also check this link : https://help.salesforce.com/articleView?id=000004964&type=1

Can you please Let me know if it helps or not!!!
Ajinkya WankhedeAjinkya Wankhede
try below query it works
Select ID ,Name FROM User WHERE isActive = false
Ram RajatRam Rajat
try Select ID ,Name FROM User WHERE isActive = false  satta king (https://deshawaroffice.com)
Suraj Tripathi 47Suraj Tripathi 47
Hi Rahul,

"Try this code."
public Class FetchUser{
   public static void fetchActiveUser(){
         List<User> getInactiveUSer=[Select ID ,Name,isActive FROM User WHERE                                                  isActive=false];
         System.debug('InActive Users are-->: '+getInactiveUSer);

        }catch(Exception e){
System.debug('Exception due to-->: '+e.getMessage());

If you find your Solution then mark this as the best answer. 

Thank you!

Suraj Tripathi