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
Jyosi jyosiJyosi jyosi 

Callout through tirgger compare the old and new values

Hello Everyone,

I have a webservice where i need to compare the old and new value if i have the  old values i need to send it another method for other i need to send in another method in webservice callout.
Need to collect the parent and child old and new values.
I wrote the trigger but i always get the new values when i send it how can i get the old values 

if(Trigger.isUpdate && Trigger.isbefore){
        XXXX.ABC(trigger.newMap.keySet());
    }

public static void ABC(Set<Id>SampleLineItem) in this method i need to acheive the old and new values.
  {
  // Map<Id,Sample_Line_Item__c> Sample_Line_Item__c= new Map<Id,Sample_Line_Item__c>();
    List<Sample__c> LstSampleQuery= new List<Sample__c>();
   Set<Id> SetSampleIds= new Set<id>();
    Map<Id, Sample_Line_Item__c> LstSampleLineItems = new Map<Id, Sample_Line_Item__c>([select Id,Line_number__c,Unit_of_Measure__c,Delivery_Group__c,Product_No__c,Sample__c from 
                         Sample_Line_Item__c where Id IN:SampleLineItem and Line_Number__C!=null order by Name  Asc]);

Thanks for help
Daniel BallingerDaniel Ballinger
You shouldn't need to make a SOQL query to get the old values. You can use Trigger.oldMap (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm) to access the existing values. 
 
string lineNumberBeforeUpdate = Trigger.oldMap.get(sampleLineItemId).Line_number__c;


See also: How to reference old or prior field value in apex trigger? (https://help.salesforce.com/apex/HTViewSolution?id=000181625&language=en_US)
Jyosi jyosiJyosi jyosi
Thanks you .i am making a callout by using future where i cannot loop sobject directly.
Is there any workaround how to get the old values.


Thanks

 
UC InnovationUC Innovation
Before calling your future method, you can probably just create two maps that stores your new and old values that you need, and then pass the two maps to your future method.  That way, you'll satisfy the @future parameter requirement of "collections of primitive data types".