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
Nag Raj 32Nag Raj 32 

Variable does not exist:Name

Hi,
please help this,

User-added image
 
Error:Variable does not exist:Name
Raj VakatiRaj Vakati
trigger AccEx on Account (before insert) {
    List<String> mynames = new List<String>();
    for(Account acc :Trigger.new){
        mynames.add(acc.Name);
    }
    
    List<Contact> con =[Select Id from Contact where Account.Name IN : mynames] ;
    
    delete con ;
}

 
Shamsi 110Shamsi 110

You are basically providing account name in the filter but matching with the contact name in the query.

Your query should be like this.
Select Id from Contact where Account.Name IN : mynames

Tip
Change myname to Set as i guess you want always it to be unique.

KIndly mark my answer, if it helps you.

Thanks,
Hasan SHamsi

 
Nag Raj 32Nag Raj 32
No ,its org problem,in other org its didn't throw error. Thanks & Regards