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
Giddamreddi ReddyGiddamreddi Reddy 

insert records in triggers

how to insert 3 records with diff names at time using triggers ?
salesforce mesalesforce me
Hi check this once...
 
trigger AccountSVOC on Account (after update) 
{
    List <SVOC__c> SVOCs = new List <SVOC__c> ();
   
    System.debug('Chris in trigger');

    for(Account a: Trigger.new) 
    {
        System.debug('Chris in account loop');
        if( (a.SVOC__c != null ) && (a.SVOC__c != Trigger.oldMap.get(a.Id).SVOC__c) )
        { 
            System.debug('Chris in status changed');
            SVOC__c SVOC = new SVOC__c ();
            SVOC.SVOC_ID__c = a.Id;

            System.debug('Chris creating new SVOC and adding to list');
            SVOCs.add(SVOC);
        }
    }

    if(SVOCs.size()>0)
    {
        System.debug('Chris has values to insert = '+ SVOCs.size());
        try{
            insert SVOCs;
        }catch (System.Dmlexception e)  
        {
             system.debug (e); 
        }
    }
}