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

how to get the latest Lead object data before its saved

Hello All,


           I need to pick the one field value of the Lead Object before its inserting to modify the another object data. I have wrote one trigger with context variable, but here i get the list of new objects. But , I need to get only the latest object before it saving.



           Can anybody please suggest me how can i get the latest Lead object data before its saved.






Salesforce uses bulk trigger, so you will always get a list. In most cases the list will only contain one record but if you use ex. the dataloader the trigger is fired for every 200 records and you will get 200 records in the list per call



If the Lead is being inserted, then is where the value will be stored since there is no 'old' value.

If the Lead is being updated, then Trigger.old is where the previous/old value will be stored.