function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
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 ; }
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