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
pooja biswaspooja biswas 

old account records

Hi
I am trying to understand trigger basics, so I have an custom field HelloWorld in acocunt object and when I create a new record I am updating the custom field with some value and the code is working
My requirement is to update the custom field in the old account records also.
How to access old record records?
Pls let me know.
public class HelloWorld
{
   public void Display(List<Account> acc)
    {
       for(Account val:acc)
       {
           if (val.Hello__c == null)
                 val.Hello__c='World';
       }
    }
} 

trigger trgupd_hello on Account (before Insert,before update,before delete,after insert,after update,after delete,after undelete)
{
      if (trigger.isBefore) 
      {
           if (trigger.isInsert)
           {
               HelloWorld obj_hello=new HelloWorld();
               obj_hello.Display(trigger.new);  
            }
     } 
}

Thanks
Pooja Biswas
Best Answer chosen by pooja biswas
~Onkar~Onkar

You want updated all stored account object data? 

If Yes, Be aware It will cause the recursive trigger, Base on event you mentioned in trigger.(before Insert,before update,before delete,after insert,after update,after delete,after undelete)

~Thanks,
Onkar Kumar
 

All Answers

~Onkar~Onkar

You want updated all stored account object data? 

If Yes, Be aware It will cause the recursive trigger, Base on event you mentioned in trigger.(before Insert,before update,before delete,after insert,after update,after delete,after undelete)

~Thanks,
Onkar Kumar
 
This was selected as the best answer
pooja biswaspooja biswas
Hi
I do not want to update all records.
only for those records whose Hello__c is not updated .
Pankaj_GanwaniPankaj_Ganwani
You can use either Dataloader or one time batch script to update all existing records where Hello__c is equal to NULL.
pooja biswaspooja biswas
Hi pankaj

so I cannot achieve my requirement using trigger.
fine , then I can go with data loader.

Thanks
pooja