Apex Triggers - 46 (Deloitte Interview Scenario)

Поділитися
Вставка
  • Опубліковано 27 лип 2024
  • 💻 Join the Titan Community : Discover Exclusive Insights on LinkedIn / mycompany
    💻 Explore the Power of Titan : Visit Our Official Website Now 🔗 titandxp.com/
  • Наука та технологія

КОМЕНТАРІ • 29

  • @arunimakashyap6207
    @arunimakashyap6207 5 місяців тому

    Great video and great channel for learning😊

  • @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

  • @goldylodhi2116
    @goldylodhi2116 5 місяців тому +1

    Nice explanation sir 🎉

  • @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

  • @kumareshghosh5593
    @kumareshghosh5593 5 місяців тому +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  5 місяців тому +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.

  • @yashwanthkumar4890
    @yashwanthkumar4890 2 місяці тому

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

  • @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

  • @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

  • @dikshapandey8590
    @dikshapandey8590 5 місяців тому

    This can easily be done by flow as well

  • @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 5 місяців тому +1

    what was the total experience of the candidate?

  • @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 28 днів тому

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

  • @srikanthsareddy54
    @srikanthsareddy54 3 місяці тому

    Ur explanation is worst

    • @sfdcninjas
      @sfdcninjas  3 місяці тому

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