Apex Triggers - 46 (Deloitte Interview Scenario)

āđāļŠāļĢāđŒ
āļāļąāļ‡

āļ„āļ§āļēāļĄāļ„āļīāļ”āđ€āļŦāđ‡āļ™ • 29

  • @diobrando1253
    @diobrando1253 3 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    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

  • @arunimakashyap6207
    @arunimakashyap6207 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Great video and great channel for learning😊

    • @sfdcninjas
      @sfdcninjas  5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Thanks

  • @diobrando1253
    @diobrando1253 3 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    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

  • @yashwanthkumar4890
    @yashwanthkumar4890 2 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Sir, what if there are more than 10k contact records from the SOQL query? How do we handle that scenario?

  • @kumareshghosh5593
    @kumareshghosh5593 6 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +2

    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

    • @sfdcninjas
      @sfdcninjas  6 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +2

      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.

  • @arnabmukherjee9225
    @arnabmukherjee9225 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    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 !!

    • @sfdcninjas
      @sfdcninjas  5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Yes we can use list to store account ids but it is better to use set as we cannot have duplicates in it

  • @goldylodhi2116
    @goldylodhi2116 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +1

    Nice explanation sir 🎉

    • @sfdcninjas
      @sfdcninjas  5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Thanks

  • @saikrishna2972
    @saikrishna2972 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Just wondering this can be implemented with formula as well right ðŸĪ” . Why to code ?

    • @bhaskarjha2736
      @bhaskarjha2736 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Correct, Interviewer may ask these kind of questions, to check skills & approach

  • @biswaranjanpratihari858
    @biswaranjanpratihari858 3 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    SIr , can't we use relationship soql here?

  • @user-cy4vt5fu6b
    @user-cy4vt5fu6b 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    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 .

    • @sfdcninjas
      @sfdcninjas  5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Sure i will create a video on it , can please tell me is this scenarios asked in some company?

  • @RahulKumar-fk9iw
    @RahulKumar-fk9iw 6 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +1

    what was the total experience of the candidate?

    • @sfdcninjas
      @sfdcninjas  5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      2-3 yrs

  • @dikshapandey8590
    @dikshapandey8590 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    This can easily be done by flow as well

  • @SachinM1985
    @SachinM1985 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Hi Sir, you told that you will make video on usage of Map, we are waiting for it. Please 🙏

    • @Leo_music2684
      @Leo_music2684 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      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..

    • @sfdcninjas
      @sfdcninjas  5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      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.

    • @SachinM1985
      @SachinM1985 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Thank you sir

  • @rajenderv5442
    @rajenderv5442 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    your voice not clear and your explanation very hurry please explain slowly

  • @srikanthsareddy54
    @srikanthsareddy54 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Ur explanation is worst

    • @sfdcninjas
      @sfdcninjas  4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Please tell me how can i improve

  • @bhaskarjha2736
    @bhaskarjha2736 5 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    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();
    }
    }