Apex Triggers - 31 (Infosys Interview Trigger Scenario)

  Рет қаралды 9,159

SFDC Ninja

SFDC Ninja

Күн бұрын

Пікірлер: 26
@TheSatyam69
@TheSatyam69 7 ай бұрын
Great code until line 42. We are unnecessarily querying account again and looping it. We could have done it in 2-3 lines. You don’t need to query account again, you may create an instance and assign Id. Thanks.
@spblore
@spblore 2 ай бұрын
Instead of this approach may be we can try query and get Case records which are status closed there by we dont need OldMap in that case..and we can keep the count using aggregateresult..instead of loops?isnt it
@abhijeetvaishnab7738
@abhijeetvaishnab7738 2 ай бұрын
provide trigger operations also like in this case it shd be - trigger CaseTrigger on Case(after update,after delete,after undelete){}
@AnmolAgrawal-sc5ll
@AnmolAgrawal-sc5ll 10 ай бұрын
bro no doubt you are doing great but please give a good description of scenario here you are telling update accoun ton basis of closed cases so we are assuming it will be on account object you would have tp give better description like when we change or insert cases then update account this looses motivation bcoz our reasoning fails due to wrong questions
@prithviprasad3476
@prithviprasad3476 Жыл бұрын
Hello can you please let us know how you are getting this scenarios , if the questions are available in more content it will help to practice as our own as well
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi Prithvi, I have reached out to experienced professionals and individuals who have undergone interviews at various companies in order to gather insights and information regarding different scenarios.
@truthteller2237
@truthteller2237 Жыл бұрын
Can you also make videos on not only triggers but also on apex classes which are used for different functionalities. That will be very helpful.
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi , Yes i have that in my plan dont worry you wil get it soon
@BalajiBalaji-jv1gt
@BalajiBalaji-jv1gt Жыл бұрын
When aggregating the case object is it not possible to write sub query of account.?
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi buddy sorry for late reply actually it is not a good practice to use sub query
@shubhamsri.1895
@shubhamsri.1895 Жыл бұрын
in my Case Status field CLOSED picklist is not showing. Only New, Working, Escalated is visible. How to view Closed option?
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi Shubham , I have already explained that issue in video please see from 14:00
@rajnishkumarsingh8110
@rajnishkumarsingh8110 Жыл бұрын
@sfdc ninja At what experience level do they ask this type of questions?
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi Rajnish , this question was asked to a person with 1.8 years of experience.
@rajnishkumarsingh8110
@rajnishkumarsingh8110 Жыл бұрын
​@@sfdcninjas Thanks for reply :)
@hareeshaddanki7623
@hareeshaddanki7623 Жыл бұрын
Please Can you share code
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi Hareesh , all codes will be available on website soon don't worry.
@hareeshaddanki7623
@hareeshaddanki7623 Жыл бұрын
@@sfdcninjas thanks
@varikutivenkatesh6680
@varikutivenkatesh6680 Жыл бұрын
Write a Test Class For that Triggers.
@sfdcninjas
@sfdcninjas Жыл бұрын
Hi Venkatesh , yes buddy i have that in my plan there will be playlist of test classes for all trigger scenarios
@ankitdangre4790
@ankitdangre4790 Жыл бұрын
Same
@sfdcninjas
@sfdcninjas Жыл бұрын
don’t worry guys there will be a series on test classes
@ankitdangre4790
@ankitdangre4790 Жыл бұрын
Sir plz make a video on interview questions asked in various IT companies .
@utkarshsoni7938
@utkarshsoni7938 5 ай бұрын
Try the below one the below code will work in Bulk for the all the Trigger Scenario's. Trgr: -> ---- trigger AccountRatingTrgr on Case(after insert, after update, after delete, after undelete){ if(Trigger.isAfter){ if(Trigger.isUpdate){ AccountRatingTrgrCls.AccountRatingTrgrMethod(Trigger.New,Trigger.OldMap); }else if(Trigger.isDelete){ AccountRatingTrgrCls.AccountRatingTrgrMethod(Trigger.Old,null); }else{ AccountRatingTrgrCls.AccountRatingTrgrMethod(Trigger.New,null); } } } Modular Class: -> ------------- public class AccountRatingTrgrCls{ public static void AccountRatingTrgrMethod(List caseList,Map oldCaseMap){ String accountRating; Set setOfAccountIds = new Set(); Map accountMap = new Map(); List accountList = new List(); List accountListToUpdate = new List(); if(caseList!=null && caseList.size()>0){ for(Case cses : caseList){ if(cses.IsClosed__c){ if(oldCaseMap==null){ setOfAccountIds.add(cses.AccountId); }else{ if(cses.AccountId != oldCaseMap.get(cses.Id).AccountId){ setOfAccountIds.add(cses.AccountId); setOfAccountIds.add(oldCaseMap.get(cses.Id).AccountId); }else{ setOfAccountIds.add(cses.AccountId); } } } } if(setOfAccountIds.size()>0 && setOfAccountIds!=null){ for(AggregateResult agr : [Select AccountId, Count(Id) countOfCaseIds FROM Case WHERE AccountId IN: setOfAccountIds GROUP BY AccountId]){ accountMap.put((Id)agr.get('AccountId'),(Integer)agr.get('countOfCaseIds')); } } accountList = [Select Id,Rating FROM Account WHERE ID IN: setOfAccountIds]; System.debug('accountMap: '+accountMap); if(accountList.size()>0 && accountList!=null){ for(Account accounts : accountList){ if(!accountMap.isEmpty() && accountMap!=null){ accountRating=''; if(accountMap.containsKey(accounts.Id)){ if((Integer)accountMap.get(accounts.Id)==0){ accountRating = ''; }else if((Integer)accountMap.get(accounts.Id)>0 && (Integer)accountMap.get(accounts.Id)2 && (Integer)accountMap.get(accounts.Id)6){ accountRating = 'Hot'; } accountListToUpdate.add(new Account(Id=accounts.Id,Rating=(String)accountRating)); }else{ accountListToUpdate.add(new Account(Id=accounts.Id,Rating='')); } }else{ accountListToUpdate.add(new Account(Id=accounts.Id,Rating='')); } } } if(accountListToUpdate.size()>0 && accountListToUpdate!=null){ UPDATE accountListToUpdate; } } } }
@thesorcerer111
@thesorcerer111 3 ай бұрын
In your aggregate query you need to put IsClosed = true because the account can also contain open cases.
Apex Triggers - 32 (Trigger Interview Question)
11:36
SFDC Ninja
Рет қаралды 3,4 М.
UC-7 Salesforce Apex Trigger  by SREEDHAR
3:44
Sreedhar - Salesforce - INDIA
Рет қаралды 31
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 42 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 17 МЛН
UC-4 Salesforce Apex Trigger  by SREEDHAR
5:14
Sreedhar - Salesforce - INDIA
Рет қаралды 21
Apex Triggers - 45 (Infosys Interview Scenario)
13:30
SFDC Ninja
Рет қаралды 6 М.
Infosys Interview Questions for Salesforce Developer | 4+ YOE | May 2024
19:38
Slesforce in 5 minutes
Рет қаралды 10 М.
Apex Triggers - 54 (Infosys Interview Scenario)
13:07
SFDC Ninja
Рет қаралды 2,5 М.
Salesforce Admin and Developer Mock Interview by Amrapali Chakraborty - #VCGF20
31:40
Salesforce Developer Group, Vijayawada, India.
Рет қаралды 29 М.
Apex Triggers - 40 (Salesforce Trigger Interview Scenario)
13:22
SFDC Ninja
Рет қаралды 4,4 М.
Infosys Salesforce  Developer Interview Questions & Answers
22:34
Salesforce Helping Hand
Рет қаралды 2,9 М.