Apex Triggers - 46 (Deloitte Interview Scenario)
āļāļąāļ
- āđāļāļĒāđāļāļĢāđāđāļĄāļ·āđāļ 4 āļŠ.āļ. 2024
- ðŧ Join the Titan Community : Discover Exclusive Insights on LinkedIn / mycompany
ðŧ Explore the Power of Titan : Visit Our Official Website Now ð titandxp.com/ - āļ§āļīāļāļĒāļēāļĻāļēāļŠāļāļĢāđāđāļĨāļ°āđāļāļāđāļāđāļĨāļĒāļĩ
Why cant we take Map? Store accountId in ID and country in string? then get the string at the end? is this approach fatal>? pls let me know
Great video and great channel for learningð
Thanks
I think we shd also make sure if I make account country blank contacts country should get blank right? Hence null check not needed on new acc country
Sir, what if there are more than 10k contact records from the SOQL query? How do we handle that scenario?
On line 33: you are double checking accMap if it contains accountId or not, already you checked in the SOQL above in 26. Please let me know if I am wrong.
PS: very similar trigger I was asked in TCS
Hey Kumaresh, it's your call whether to add that extra check or not. But I strongly recommend doing it for an added layer of safety.
Can we use a list to store the accoundids and when we're querying on the contact object we can user Account.County__c to get the country field value from the account object.
Please correct me if i am wrong !!
Yes we can use list to store account ids but it is better to use set as we cannot have duplicates in it
Nice explanation sir ð
Thanks
Just wondering this can be implemented with formula as well right ðĪ . Why to code ?
Correct, Interviewer may ask these kind of questions, to check skills & approach
SIr , can't we use relationship soql here?
please make video on below scenario
when lead is created and after 48 hours still that lead status is new then send mail to record owner and record owner manager .
Sure i will create a video on it , can please tell me is this scenarios asked in some company?
what was the total experience of the candidate?
2-3 yrs
This can easily be done by flow as well
Hi Sir, you told that you will make video on usage of Map, we are waiting for it. Please ð
Please mee too.. Many of times I get confused why to make things complicated when we can use List instead of Map...and why do we use Map and when to use it in first place is something I never understood....Please help us in making a detail video on Maps..
in next video i am going to explain it donât worry and if you will be able to understand it then please share it.
Thank you sir
your voice not clear and your explanation very hurry please explain slowly
Ur explanation is worst
Please tell me how can i improve
trigger TriggerOnAccount on Account(after update){
if(Trigger.isUpdate && Trigger.isAfter){
AccountTriggerHandler.afterUpdate(Trigger.newMap,Trigger.oldMap);
}
}
public class AccountTriggerHandler{
public static void afterUpdate(Map newAccMap,Map oldAccMap){
Map updatedRegionAccountMap = new Map();
for(Account acc : newAccMap.values()){
if(acc.Region__c!=null && acc.Region__c != oldAccMap.get(acc.Id).Region__c){
updatedRegionAccountMap.put(acc.Id,acc);
}
}
if(!updatedRegionAccountMap.isEmpty()){
updateRegionOnContacs(updatedRegionAccountMap);
}
}
public static updateRegionOnContacs(Map updatedRegionAccountMap){
Map contactMap = new Map([Select Id, Region_On_Account__c from Contact Where AccountId IN :updatedRegionAccountMap.keySet()]);
for(Contact con : contactMap.values()){
con.Region_On_Account__c = updatedRegionAccountMap.get(con.AccountId).Region__c;
}
update contactMap.values();
}
}