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
mng0827mng0827 

primary contact trigger

Hi,

Can someone provide me a sample code which updates the First Name of the primary contact when the custom First Name in the account is updated?

Thanks!
Ramu_SFDCRamu_SFDC
Follow the guidelines explained in the below article

http://developer.force.com/cookbook/recipe/mass-updating-contacts-when-an-account-changes
mng0827mng0827
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;
            }           
        }
    }

    update contacts;
}