Activity Forums Salesforce® Discussions How to delete all contacts which are not related to any account?

  • PRANAV

    Member
    August 26, 2016 at 11:20 am

    Hi Tanu,

    You can delete all contacts with the help of Mass Delete Records in your org.

    • Click Your Name | Setup | Data Management | Mass Delete Records Or search in Quick Search box.
    • Select the Mass Delete Contacts option.
    • In Find Contacts that match the following criteria: choose AccountId equals to blank means no need to write in third box.
    • Select search, here you find all the contacts which are not related to any account.
    • Now select the contacts you want to permanently delete.

    Hope this helps you.

    Thanks

     

  • Piyush

    Member
    August 26, 2016 at 2:35 pm

    Hello ,

    Try this sample of code to delete the contacts which are not associated with Account.

    List<Contact> conList =[select Id,Name from contact where AccountId = null];
    System.debug('List of contacts Whoes Account Id is null'+conList);
    delete conList;

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos