You need to sign in to do that
Don't have an account?
Adarsh Nandan
Actually I am getting Problem to use Map and Set
Actually I am Fresher I need some help When i use Map and set in apex and How can I use It . Please Send me the best Way to learn Map and Set and Also Confusion in AFter Delete and before Delete?
We use map when we need collection of key-value pairs where each unique key maps to a single value.
e.g., How to use List?
List is nothing but an order collection of data. It's an Array of one particular Data Type. But however, in salesforce you can have SObject as a Data Type as well.
e.g., Remember: Lists can have duplicate values in it. You can surly add numbers.add(1); again and it's index would be 4.
What is After Delete inside an Apex Trigger?
let's say you are counting number of Conatct on Account. Now, you are deleting one Contact from Account's related list. At this point how would account know that it now one contact less? In other words if there are 5 conatcts per Account then you have a Roll-Up trigger which counts total number of Cons on Account with value of 5. If you delete 5th contact then how would Account record would update with 4 instead of 5 in Total_Contacts__c field? Because you are not touching Account object at all.
Above, is the scenario where you write After Delete inside your trigger parameters because you are telling trigger that RUN even if the record is deleted.
Samething goes for all other parameters events such as Before Insert, Before Update, After Delet, After UnDelete, ......etc..
Events tells the trigger when to run.
Hope it helps & if it solves the question then please mark it as best answer since it will help other users in community as well!