Thanks Ramu. I tried creating the trigger but can seem clear out this error:
Error: Compile Error: expecting a right parentheses, found 'Select' at line 6 column 51
Can you help me fix this? Here's my code: _____________________________________
trigger UpdatePrimaryContact on Account (before insert, before update) { List<Contact> contact = new List <Contact>(); for(Account acct: Trigger.new){ contactIDs.add (contact.FirstName); } List<Contact> ContactList = new List <contact>(Select Id, AccountId, FirstName, isPrimary__c from Contact where AccountId in :AccountIds ORDER BY isPrimary__c ASC, createdDate DESC]); for (Account acct: trigger.new){ for (integer i = 0; i <Contacts.size(); i++){ if (Contact.FirstName == contacts[i].id){ contacts[i].FirstName = First_Name__c from Account; } } }
http://developer.force.com/cookbook/recipe/mass-updating-contacts-when-an-account-changes
Error: Compile Error: expecting a right parentheses, found 'Select' at line 6 column 51
Can you help me fix this? Here's my code:
_____________________________________
trigger UpdatePrimaryContact on Account (before insert, before update) {
List<Contact> contact = new List <Contact>();
for(Account acct: Trigger.new){
contactIDs.add (contact.FirstName);
}
List<Contact> ContactList = new List <contact>(Select Id, AccountId, FirstName, isPrimary__c from Contact where AccountId in :AccountIds ORDER BY isPrimary__c ASC, createdDate DESC]);
for (Account acct: trigger.new){
for (integer i = 0; i <Contacts.size(); i++){
if (Contact.FirstName == contacts[i].id){
contacts[i].FirstName = First_Name__c from Account;
}
}
}
update contacts;
}