Skip to main content Rejoignez-nous lors de l'événement TDX à San Francisco ou sur Salesforce+ les 5 et 6 mars pour la conférence des développeurs à l'ère des agents IA. Inscrivez-vous dès maintenant.
1 réponse
  1. 20 sept. 2022, 08:34
    Hi Switi,

    Can you try the below Trigger on Account object.

     

    trigger AcountConDelete on Account (before insert) {

    set<String> namestr= new Set<String>();

    for(Account acc:Trigger.new){

    namestr.add(acc.name);// Adding name to set

    }

    List<Contact> tobedeleted= [select id,name from contact where name in :namestr];//quering the contacts with that name

    if(tobedeleted.size()>0)

    delete tobedeleted;

    }

    Let me know if you face any issues.

    If this solution helps, Please mark it as best answer.

    Thanks,
0/9000