You need to sign in to do that
Don't have an account?

Trigger.newMap Vs Trigger.oldMap
i need programatic code explantion ple any one have ideal send me .
You need to sign in to do that
Don't have an account?
i need programatic code explantion ple any one have ideal send me .
this might help
http://developer.force.com/cookbook/recipe/comparing-queries-against-trigger-old-and-trigger-new
Hi,
Suppose you have an opportunity object. And you want to trigger on Stage field.
You have after/before update trigger on opportunity, which should be fired only when stage is changed. I this case we can use Trigger.Old. See below example
I hope this will helpfull to you. Let me know if you have more question.
Trigger.OldMap: Trigger.oldMap returns map of old records which are updated with new values. These List of records already there in Database. Trigger.oldmap available in Before update, after update, Before Delete and After Delete triggers.
Trigger.NewMap: Trigger.newMap returns map of new records which are trying to insert into Database. This is available in Before Insert, Before Update, After Insert, After Update Triggers and undelete Triggers. This list of records can only modified in Before triggers.
for(Account Acc:trigger.new){
if(trigger.isupdate){
Account oldaccount = new Account();
oldaccount = trigger.oldmap.get(Acc.id); // trigger old map to get old value(existing value) of the record
if(oldaccount.CreditStatus__c !=Acc.CreditStatus__c ){
Acc.CreditstatusDate__c = system.today();
system.debug('uuuuuuuuuu'+userinfo.getName());
}