Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
How to get previous stored lookup value in lookupfield.
5 answers
  1. Apr 29, 2015, 4:13 PM
    if you are using custom controller you can save the inital lookup value to a variable on page load and compare it  to with the record value on save 
  2. Apr 29, 2015, 1:36 PM
    I like to get the field value before submit the record
  3. Apr 29, 2015, 11:14 AM
     for (your_Object__c urobject :Trigger.new)

         {

             if(Trigger.oldMap.get(urobject.Id).Lookupvalue__c != urobject.Lookupvalue__c)

             {

                urobject.OldLookupvalue__c = Trigger.oldMap.get(urobject.Id).Lookupvalue__c

             }

         }

    replace your_object__c, Lookupvalue__c , OldLookupvalue__c  with respecitve api Names
  4. Apr 29, 2015, 10:56 AM
    give apex code for get previous value for lookupfield
  5. Apr 29, 2015, 10:04 AM
    you can enable the history tracking  for that field  and use field history records to determine the old value or you can maintain a another lookup field  and write the old value to that field on lookup field value change. you can use Trigger.OldMap to find the old value in a trigger
0/9000