+ Start a Discussion
r nareshr naresh 

How to get old phone filed values after i update with new phone filed value using trigger

please give me example Thank u in advance
For getting the old values in a trigger you can user Trigger.oldMap. Here is the detailed description about this - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm. Please go through "Context Variables Considerations" section too, to understand the whole funda better.

Eg code:
trigger YourTriggerName on ObjectName (before update) { 
      // Some code here
      String oldPhone;
      for (ObjectName var : Trigger.new) {
             // Access the "old" record by its ID
             oldPhone = Trigger.oldMap.get(opp.Id);
             // More code logic here
Does this help? Do you need more information.

Abhishek BansalAbhishek Bansal
You can use below syntaxt in your trigger :

OldPhoneValue = trigger.olMap.get(contact.id).Phone.

NOTE : trigger.oldMap is only available in update and delete triggers.

My bad... Code should be: oldPhone = Trigger.oldMap.get(var.Id).APINameOfPhoneField; instead of oldPhone = Trigger.oldMap.get(opp.Id);.