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
vivek singh 20vivek singh 20 

please help this is my trigger in opportunity when the trigger working in contact roles 2 field updated pleae help how we update only one contact role made

Example--

Contact Roles
Contact Roles Help Contact Roles Help (New Window)
Action Contact Name Company Name Email Phone Role Primary
Edit | Del Brown IBM   123123123123   Checked                                                               
Edit | Del Brown IBM   123123123123 Buyer

triger--
____________

trigger OpportunityTrigger on Opportunity (After insert)
{
    if(trigger.isAfter && trigger.isInsert)
    { system.debug('After insert');
        opportunityTriggerHandler objopportunityTriggerHandler = new opportunityTriggerHandler();
        objopportunityTriggerHandler.createNewContact(trigger.new);
    }
}
__________________________
class
-------------------------
Public class opportunityTriggerHandler
{
   
    public void createNewContact(List<Opportunity> triggerNew)
    {
        List<OpportunityContactRole> lstOppContactRole = new list<OpportunityContactRole>();
        if(triggerNew != null && triggerNew.size() > 0)
        {
            for(Opportunity objOpp : triggerNew)
            {
                if(objOpp.Buyer__c != null)
                {
                    OpportunityContactRole objOppContactRole = new OpportunityContactRole();
                   
                    objOppContactRole.ContactId = objOpp.Buyer__c;
                    objOppContactRole.OpportunityId = objOpp.ID;
                    objOppContactRole.Role = 'Buyer';
                   
                    lstOppContactRole.add(objOppContactRole );
                }
            }
        }
       
        if(lstOppContactRole.size() > 0)
        insert lstOppContactRole;
       
    }
}
vivek singh 20vivek singh 20
please reply