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
Maverick123Maverick123 

Get Trigger.New instance values in AfterInsert/AfterUpdate Operation

Hi Friends,

Is there any way of getting Trigger.new values in AfterInsert / AfterUpdate operations, i know we cant get in normal trigger operations.

Is there a possibility we can store it somewhere in a before instance and then reuse it in the after update operations. Please advice.

Thanks,
Maverick
kiranmutturukiranmutturu
If i am not wrong you want to access the trigger.new list in after insert or after update right? If yes you can access this list in both of these events...
Maverick123Maverick123
Hi Kiran, i need to access the trigger.new and trigger.old for after insert/update, but the values in both the list is same....
mahendar mmahendar m
trigger.old list containss old instance values ,while trigger.new new instance  .for example if suppose  a status field on the  lead object contains(good,best,better).see ,if i want to change the the status value with a"good" to "best"(while updating).The status value "good " available only in trigger.old while status with"best" vaule exist in trigger.new.  
Maverick123Maverick123
Hi Mahendar,

Thanks for the reply...but now as per your example try accessing the status values in the after update operation, both trigger.old and trigger.new would give you status as 'best'....what i am looking for here is i need the value 'Good' in the after update operation. Hope this helps...

Regards,
Maverick


mahendar mmahendar m
Hello Maverick123Maverick123,

lead oldValue = new lead();
for(lead l:trigger.new){
     
        oldValue = System.Trigger.oldMap.get(l.Id);
}
string oldstatusValue = oldValue.status;

May be it helps you
Regards,
Mahendar.