Salesforce Coding Interview with Salesforce MVP | Part 2 | By Salesforce Engineer

Sdílet
Vložit
  • čas přidán 4. 04. 2020
  • In this video, I conduct a mock Salesforce Coding and Admin interview with Salesforce MVP, Narender Singh. I have conducted many interviews for Salesforce in the past 3 years and you will get to feel a real interview setup in this video. Most of product tech companies follow similar interview pattern.
    Checkout part1 of this interview here: • Salesforce Admin Inter...
    Follow Narender on twitter @Nads_P07
    Become a patron and support my work here: / sfdcfacts
    Please share this video and subscribe to the channel if you love my content.
    Content By: Manish Choudhari
    Editor: Manish Choudhari
    Website: sfdcfacts.com
    Twitter: / manish_sfdc
    LinkedIn: / manish-choudhary

Komentáře • 90

  • @SFDCFacts
    @SFDCFacts  Před 4 lety

    ****FREE LWC COURSE VOUCHER*****
    Are you someone or do you know someone who recently appeared for a Salesforce Developer interview at Google/Amazon/Uber/Salesforce or any major product company?
    Then reach out to me at *sfdcfacts@**gmail.com* to share your interview experience and get access to LWC udemy course for FREE!!!!!

  • @lokeshkumar3163
    @lokeshkumar3163 Před 4 lety +67

    Point is the static variable maintain it states throughout the transaction until you set another value.
    The Batch size is 1000 so all updates will be synchronous and there will be only one batch thread of size 1000.
    Trigger consider a batch of 200 records and process it synchronously, in this case, the processing will be divided in 1000/200 = 5
    and from 1st record till 200th the value will be true and after that, the value will be set to false due to the condition written outside the loop and once it is set to false it remains same until it is updated so for all the other from 201 -1000 records the value will be False.
    I hope it explains the answer in detail.
    1st true
    50th true
    100th true
    201st false
    250th false
    500th false
    1000th false

    • @SFDCFacts
      @SFDCFacts  Před 4 lety +4

      Correct :)

    • @Psychologyfacts541
      @Psychologyfacts541 Před 4 lety +1

      So sir, is it possible at 400 =false and 401=true right 500 = true

    • @anuragnarang26
      @anuragnarang26 Před 3 lety +1

      U sure? Doesn't it depends on database.stateful? If its implemented or not.

    • @KapasiTejasVideos
      @KapasiTejasVideos Před 3 lety +4

      @@anuragnarang26 use database.stateful if you want to maintain the state of any local batch variable across the batch transactions. Here it's more about Trigger context because batch execution method is trying to insert 1000 contacts which basically fires the trigger and hence Database. stateful not relevant here.

    • @ourmoments7800
      @ourmoments7800 Před 3 lety +3

      I have a question. As you rightly said the trigger will consider it as 5 chunks each consisting of 200 records. But my doubt is will it be 5 different transactions as the trigger logic will be executed 5 times for each chunks. If that's the case then the static variable will be initialised 5 times right? Or is it like it will be a single transaction wherein chunk 1 processed synchronisly, and then chunk 2 records processed synchronisly and so on. In short is it 5 transaction or just 1? Any help would mean alot

  • @gaurichaudhari1201
    @gaurichaudhari1201 Před 2 lety +7

    Good Interview. I tried and tested. I wrote same trigger with same handler class. I inserted 1000 records, for first batch the values are true. 1-200 true. all the batches after that are false. hence 1st true
    50th true
    100th true
    201st false
    250th false
    500th false
    1000th false

  • @pkcreations6034
    @pkcreations6034 Před 4 lety +4

    This is amazing , lots of learning on single video and it's interesting. Much appreciated . Please do more.

  • @santoshparit1244
    @santoshparit1244 Před 2 lety

    This is amazing , lots of learning on single video and it's interesting. Much appreciated .

  • @manj3125
    @manj3125 Před 4 lety +1

    For the question on before and after trigger, since it is update operation it will work in before trigger also because the account ID is already present, but if it was insert operation it would not work.

  • @AshwaniKumar-bf4vj
    @AshwaniKumar-bf4vj Před 3 lety +1

    Trigger.new will hold the batch of 200 records so it maked 5 threads of 1000 records. Since myVar is static variable it will hold its state across transaction.
    Chunks of records and myVar value: 1-200(true) 201-399(false) 400-600(false) 601-799(false) 800-1000(false)

  • @Magical_Souls
    @Magical_Souls Před 2 lety

    For assigning inserted account record id to what Id we have to choose " After Update" , record id value won't be available for 'before insert

  • @chatoanil
    @chatoanil Před 4 lety +1

    Thank u Manish.

  • @manj3125
    @manj3125 Před 4 lety +1

    For Creating Tasks and Events - use WhatID and WhoID based on the respective object.

  • @qarora
    @qarora Před rokem

    basically Batch begins the transaction ..
    Now, it passes chunks of 200 records each time while processing the records i.e., execute method.
    Now, since the DML would be in execute method, the trigger will be invoked 5 times in this particulr scenario.
    Now comes the tricky part, trigger's handler would also be called 5times so it would initialise the value of the variable 5times.
    Note that the variable itself is static but it is not in the context of the separate transaction that batch's current chunk has created, so it will reset after 200records.
    Hence,
    1-199 - TRUE
    200 - FALSE
    201-399 - TRUE
    400 - FALSE
    401-599- TRUE ...

  • @phabove7
    @phabove7 Před 3 lety +2

    I don't know if my approach makes sense, but I would choose between "After Update" and "Before Update" events based on how important it is to complete "Account Update" operation vs "Task creation".
    Let's say, Task creation is so crucial that Account shouldn't be updated without it. Then, I would go for "Before Update", because if "Insert Tasks" DML fails, the transaction should be terminated.
    But, for most practical reasons, Account update does a lot more job and it shouldn't be dependent on Task creation. In that case, we may go for "After Update", with Exception Handling for "Insert Tasks" DML.

  • @nareshs4748
    @nareshs4748 Před 4 lety +4

    Good one Manish , was that guy really MVP What is qualification for MVP .. no need of practical knowledge ? .. These are some basic day to day stuff for hard core SFDC developers

  • @divyaagarwal6844
    @divyaagarwal6844 Před 4 lety

    Good stuff Manish.
    Would be helpful if you add more questions based on trigger scenarios,order of execution scenarios

  • @rushikeshmane2297
    @rushikeshmane2297 Před rokem

    really helpfull Manish🤩please add more to this playlist..thanks

  • @shubhamdhupar523
    @shubhamdhupar523 Před 4 lety

    The new task apex code will work well on before update but if the conditions were different and we had to implement for INSERT as well, it won't work on BEFORE INSERT because no commit would have taken place and we won't have an account Id to associate with the task.
    The question to use before or after suits better when dealing with Insert

    • @aamirahmad5817
      @aamirahmad5817 Před 3 lety

      and also old and oldMap are not available in an insert context, so it would give an error

  • @harshasuman2369
    @harshasuman2369 Před 4 lety +5

    Hello Mainsh,
    These videos interviews were really great. I do have experience few interviews and everyone is asking scenario based questions like you framed in your videos, can you help with more videos like that and also if you could suggest where do I practice more of these scenario based questions as mostly in google I am getting theory questions.
    Thanks!!

  • @meenakshipochincharla8714

    Hi Manish,
    Great work,
    Please post more questions on trigger-based scenarios

  • @shoottkuruvi9856
    @shoottkuruvi9856 Před 4 lety +2

    Thanks for this Manish. As per my understanding of the concept, for the first transaction the variable value will be true, once the chunk is processed and from the second chunk the value will be false because it was initialized only once......for making all the chunks to print as true what should be the approach, please give ur thoughts on this.....

  • @HVadlamudi
    @HVadlamudi Před 2 lety

    Thanks for the trigger.oldMap on if condition that i never tried before.

  • @revathyharidas3950
    @revathyharidas3950 Před 4 lety +3

    For the question related to updating 1000 contacts, I don't see how that static variable is affecting the data update. I tried the same code snippet in my dev org and inserted all 1000 records and updated the email for all records to empty. The static variable becomes false after the first instance of the trigger but there is no condition check using that before email field update so why 201 st record will fail ????

    • @bratatibarman9963
      @bratatibarman9963 Před 4 lety

      Hi Revathy I am started learning Salesforce by my own...by watching vedios and through the trailhead...but want some guidance as well. Specially for interview preparation... I want guidance from someone who is wory in Salesforce. I think u r working in this field. Could you please help me in this?? It will be really grateful for me...I can share my mail id for further discussion if you want..plz help

    • @revathyharidas3950
      @revathyharidas3950 Před 4 lety

      @@bratatibarman9963 Bratati, I think you are on the right track by following tutorial videos and trailhead.
      Try to work on the projects and super badges available in the trailhead that way you will get hands-on experience. And go through the salesforce documentation like Apex doc, lightning etc.
      Try to implement in developer org while you learn, be it configuration part or customization.
      Hope this helps, best of luck :)

    • @bratatibarman9963
      @bratatibarman9963 Před 4 lety +1

      @@revathyharidas3950 thanks for the info 👍

    • @kd-1-9942
      @kd-1-9942 Před rokem

      Because 1st batch of 200 gets finished. For second batch it will call that method again but will not reinitiate static variables.

  • @nandkishornaikwadi8377
    @nandkishornaikwadi8377 Před 4 lety +2

    All debug commands will print true, As each for loop works for batch size and after completing for loop of that batch it sets variable to false(which will be never printed), for next batch variable is again initialised to true and it will print true for complete batch. The same logic will repeat for each batch.
    Kindly correct me @manish if i'm forgetting something !
    You are doing a great job 👍

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      Incorrect Nandkishor, give it another try. 🙂

    • @nandkishornaikwadi8377
      @nandkishornaikwadi8377 Před 4 lety +1

      @@SFDCFacts according to my knowledge it completely depends upon batch size which we define in executeBatch statement. Here you haven't mentioned anything about it, so i considered default batch size of 200.
      In this case each debug statement will print TRUE.
      If we define batch size equal to 1000, then upto 200 it will print TRUE(as trigger will process 200 records at a time) and after that for remaining records it will print FALSE.
      Hopefully i'm approaching it right 😀

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      I did mention about the batch size if you listen to the video, it is 1000. 😊

    • @nandkishornaikwadi8377
      @nandkishornaikwadi8377 Před 4 lety +2

      @@SFDCFacts oh! I completely missed it !
      Thanks for correction 👍
      If batch size is 1000, then for first 200 debug statements it will print TRUE and after that it will print FALSE for every debug statement.

  • @amithajare6039
    @amithajare6039 Před 4 lety +1

    Thank you Manish both the parts were really good.
    I have a question is there any source to learn and improve time and space complexities?!

    • @SFDCFacts
      @SFDCFacts  Před 4 lety +1

      Yes, lost of them. Try searching big O notation on google/youtube and you will get plenty of results.

  • @ArunKumar-hp8ue
    @ArunKumar-hp8ue Před 4 lety +2

    Hi Manish,
    Great work from your side, it will help for sa many people to get some info👍🤝
    Answer for the 1st question is:
    As you mentioned batch size is 1000, so far myvar also static variable because for entire transaction will run in only one batch and update true for all.
    Thank you

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      Incorrect, give it another try.

  • @ameensams
    @ameensams Před 3 lety

    Because you are referencing an Id field which will not be set until the record has been created, using a before trigger event will not work.

  • @51madan
    @51madan Před 3 lety

    true entire outputs

  • @vinodazure2676
    @vinodazure2676 Před 4 lety +8

    Feel like this bro is doing more over Action than answering the manish questions. 🤣🤣🤣 seems I understand manishs bhai inner feeling

  • @ujjawalverma2260
    @ujjawalverma2260 Před 4 lety +1

    What was the answer of first question ?

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      Think about it 🙃 what do you think should be the answer?

  • @monstersid
    @monstersid Před 4 lety +5

    For the batch question:
    1st record update: True
    50th record update: True
    100th record update: True
    250th record update: False
    500th record update: False
    1000th record update: False
    Anything after 200 for that matter would be false as the static variable context would be maintained and as Narendar already mentioned, trigger would run in batches of 200 even though you are running the batch class with a batch size of 1000.

    • @nigamgoyal
      @nigamgoyal Před 4 lety

      I go forward with this answer

    • @chrisludovice07
      @chrisludovice07 Před 4 lety

      given if the job maintain its state. You can use Database.Stateful in your batch code.

  • @ramangandhi4221
    @ramangandhi4221 Před 4 lety +2

    1st record updates : true
    50 record updates :
    true
    100 record updates :
    true
    201 record updates :
    true
    250 record updates :
    true
    500 record updates :
    true
    1000 record updates : true
    myVar will be true each time. This is because you did not implement the Database.Stateful interface in your class, meaning variable states are not kept from one scope to another
    Manish please reply

    • @vijayv3770
      @vijayv3770 Před 2 lety +1

      I have tried the same code for 440 records and Value of variable is always true.

  • @TheBeastBananas
    @TheBeastBananas Před 7 měsíci

    WhoId instead of ownerId for Tasks

  • @alliabutool1716
    @alliabutool1716 Před 3 lety

    Hi Manish.. Give some more trigger based questions as they asked this more

  • @chrisludovice07
    @chrisludovice07 Před 4 lety

    On the first problem, if the batch size is 1000 then it would definitely print 1000 TRUEs since it will all be checked inside the LOOP even if the batch job maintain its state (Database.Stateful). Every transaction is discrete and each chunk the state of the job is reset. But if the batch size is

  • @nani1385
    @nani1385 Před 4 lety

    1st true
    50th true
    100th true
    250th true
    500th true
    1000th true

  • @heenaanif348
    @heenaanif348 Před 4 lety +3

    Thank you Manish 🙃 your video is really helpful.
    I m going to share this video in my college for my junior's.
    🍬 Chocolate for you...... for this video.

  • @dipenshah1393
    @dipenshah1393 Před 3 lety +3

    Being MVP doesn’t make you expert

    • @abcshohag
      @abcshohag Před 3 lety +5

      The purpose of this video was to share some knowledge to the audience, not to compare their expertise.

  • @tharuniganesh
    @tharuniganesh Před 3 lety

    We need answers for all questions

  • @sflearner9388
    @sflearner9388 Před 4 lety +1

    Hi Manish :
    for the 1st question I believe it will run in batches of 200, once the 200th record iteration is done, as per save order , another chunk will process but since the static variable value is now false, so , after 200th record it will always be false in that scope.
    1st true
    50 true
    100 true
    250 false
    500 false
    1000 false
    I may be wrong,so, when we will be getting the answer and explanation too, for the same.
    thanks @nads @manish for amazing video

  • @rameshgoud4970
    @rameshgoud4970 Před 4 lety +1

    Great session...The answer should be
    1st record update: true
    50th record update: true
    100th record update: true
    250th record update: false
    500th record update: false
    1000th record update: false
    only for first 200 records the value of static variable will be true after that it set to false ,then for remaining records (201 to 1000) it will be false. Please correct me if am wrong.

    • @AnuragDhaka
      @AnuragDhaka Před 2 lety

      Just tested this logic , with every chunk or batch size its new transaction and static variable will be reset , ie if it 1000 record and batch size is 200 then 1st 200 will be execute as one transaction and then next 201 to 400 will be in another transaction , this is how batch is avoiding platform limits every batch is separate transaction so in this scenario it will be true for all given 1st ,50th, 200, 201st , 500 because at then end of for loop it sets to false but in next transaction it get reset back to true

  • @biswajitsamantaray3117

    Hi friend, Can I be part of your Interview please

    • @SFDCFacts
      @SFDCFacts  Před 3 lety

      Hi Biswajit, contact me at sfdcfacts@gmail.com

  • @saurabhsood007
    @saurabhsood007 Před 4 lety +3

    Hi Manish : Below are my answers
    why true because it take 200 records in one batch and for loop run 200 times update static variable to false but again new batch of records come and static variable update to true for next instance of batch so answer are :)
    This answer will be true if code is written in trigger itself not in handler.
    1st true
    50 true
    100 true
    250 true
    500 true
    1000 true
    Let me know you thoughts ..

    • @SFDCFacts
      @SFDCFacts  Před 4 lety +2

      Incorrect answer 😜 give it another look.

    • @saurabhsood007
      @saurabhsood007 Před 4 lety

      @@SFDCFacts : My Bad, if we have handler class that time results would be different
      Static Initialization will happen only once when class is get initialized i.e. public static Boolean myVar = true;
      Once first batch of 200 got executed, myVar get updated to myVar = false and class will not get initialized again !! Because already initialized for first chunk of records
      After that it will print false value. :)
      1st true
      50 true
      100 true
      250 false
      500 false
      1000 false
      Thanks for your response.... please give your thoughts once again !! :)

  • @nagendrasingh228
    @nagendrasingh228 Před 4 lety +7

    1st true
    50th true
    100th true
    250th false
    500th false
    1000th false

    • @dkhatri1994
      @dkhatri1994 Před 4 lety +1

      Yes, batch size play the role, how may records come in trigger. But the main thing is that. Below 200 can only work in that case. If you give batch size more than 200, then trigger will run in 200 chunks and if you give below 200. Like 100 then trigger will run in 100 records chunk.

    • @dkhatri1994
      @dkhatri1994 Před 4 lety

      Correct answer.

  • @crazyboys7301
    @crazyboys7301 Před 4 lety +1

    1st true
    50th true
    100th true
    250th true
    500th true
    1000th false

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      Incorrect, give it another try.

    • @kolliramu546
      @kolliramu546 Před 4 lety

      @@SFDCFacts It will be 'true' for all iterations.

  • @kavitaupadhyaya4814
    @kavitaupadhyaya4814 Před rokem

    1 true
    50 true
    100 true
    201 false
    250 false
    500 false
    1000 false
    Please correct me if I'm wrong

  • @sidhantgupta7811
    @sidhantgupta7811 Před 4 lety

    1st true
    50 true
    100 true
    250 false
    500 true
    1000 true

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      Incorrect, give it another try.

  • @manj3125
    @manj3125 Před 4 lety

    Hi Manish,
    I think it should be the below answer. Could you please verify the answer ? at least secretly :)
    True
    True
    True
    False
    False
    False

    • @NarenderSingh-tq1wq
      @NarenderSingh-tq1wq Před 4 lety +1

      Yeah, that should be the answer. The reason I messed up was because I completely misread the question and didn't see that the condition was outside for loop. 😅

    • @manj3125
      @manj3125 Před 4 lety +1

      @@NarenderSingh-tq1wq thanks bro. Your approach on using a single automation tool made a lot of sense. Cheers for that!!

  • @ujjawalverma2260
    @ujjawalverma2260 Před 4 lety

    All are false except firstone

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      Incorrect answer 🙂 give it another look.

    • @SFDCFacts
      @SFDCFacts  Před 4 lety

      @@starman9000 Incorrect, give it another try.

    • @balamuruganvelu976
      @balamuruganvelu976 Před 3 lety

      @@starman9000 on 1000th iteration, the counter value is 1001, and exits the loop with MyVar as 'true' the if loop evaluates MyVar true and sets MyVar to 'false' and prints the value as false.