function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to find the contacts which are not related Opportunity, Note, File, Attachment, Task, Event, Activity etc


We would like to delete the contacts in production which are not linked to Opportunity, Note, File, Attachment, Task, Event, Activity etc.

Attachment, Notes,  Files, Tasks and Event objects are not supporting the semi join inner queries. 

Is there anyway i can find the Contacts records which are not used anywhere in salesforce?
Raj VakatiRaj Vakati
I dnt thnin so you can able to do in salesforce with Single SOQL 

You can explore this options 
  • Try to use Wave and see 
  • Try to export the data and use vlookup and filter 

Nandigam RajeshNandigam Rajesh
Hi Raj,
This query may helps you to find Contacts:

Select Id, Name from Contact where ID NOT IN (Select ContactId from Opportunity) AND ID NOT IN (Select ContactId from Note) etc;