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
Lon JonesLon Jones 

Access Record Prior Value in Apex

I am trying to pass a prior value as a param to a flow that I need to call from apex because I need to cover the inability to deal with deleted records without apex triggers.  Can someone lend guidance as to how to access a record's prior value? thanks

I need something like this (I know it's not that simple)

  For (Animal_Location_History__c Animal : Trigger.Old) {
      // Call the Flow
        Map<String, Object> params2 = new Map<String, Object>();
        params2.put('varInputAnimalLocation', Animal_Location_History__c.Animal_Location__c);
        params2.put('varPriorLocation', PRIORVALUE(Animal_Location_History__c.Animal_Location__c));
        params2.put('varInputAnimalLocation', Animal_Location_History__c.Location__r.Id);
           Flow.Interview.Update_Location_Inventory Update_Location_Inventory = new Flow.Interview.Update_Location_Inventory(params2);
        Update_Location_Inventory.start();
        // System.debug('Animal Location '  + Animal_Location_History__c.Animal_Location__c    );
        
        }
Maharajan CMaharajan C
Hi Jones,

Please try the below:

From Trigger.OldMap you can get the old value.
 
For (Animal_Location_History__c Animal : Trigger.Old) {
      // Call the Flow
        Map<String, Object> params2 = new Map<String, Object>();
        params2.put('varInputAnimalLocation', Animal_Location_History__c.Animal_Location__c);
        params2.put('varPriorLocation', Trigger.OldMap.get(Animal.Id).Animal_Location__c);
        params2.put('varInputAnimalLocation', Animal_Location_History__c.Location__r.Id);
           Flow.Interview.Update_Location_Inventory Update_Location_Inventory = new Flow.Interview.Update_Location_Inventory(params2);
        Update_Location_Inventory.start();
        // System.debug('Animal Location '  + Animal_Location_History__c.Animal_Location__c    );
        
        }

Thanks,
Maharajan.C

 
adam ropadam rop
LiteBlue USPS is here to help you to communicate quicker and stay connected. It comes with the information you need about career development, products, revenue and service performance, the recognition you name it. Liteblue USPS website has enabled the quick transfer of information from one employee to another employee with ease. https://liteblue.red