Skip to main content
pooja biswas ha preguntado en #Apex
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
4 respuestas
  1. 13 abr 2016, 5:18

    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

     
0/9000