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

primary contact trigger


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?

Follow the guidelines explained in the below article
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:{
    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:{
        for (integer i = 0; i <Contacts.size(); i++){
            if (Contact.FirstName == contacts[i].id){
               contacts[i].FirstName = First_Name__c from Account;

    update contacts;