Real-World Complex Trigger Solution in Salesforce - A Complete Guide
Вставка
- Опубліковано 1 жов 2024
- Trigger Scenario - Update account with number of opportunity Line Items associated.
🚀 Level Up Your Salesforce Skills! 🚀
Sign up for my Salesforce Interview Prep Course and get:
1️⃣ Access to All Recordings: Covering all the important Salesforce topics.
2️⃣ Mock Interviews: Practice and get better at interviews.
3️⃣ Community Support: Get your doubts answered anytime by our awesome community.
4️⃣ Resume Review: Personalized feedback to make your resume stand out.
5️⃣ 1:1 Career Advice: Chat with me directly about those tough career decisions.
6️⃣ Weekend Doubt Sessions: Join live Q&A sessions to clear up any confusion.
7️⃣ Helpful Notes: Quick and easy reference for your studies.
💥 All of this for just ₹499, the lowest price ever! Plus, you can check out the free preview to see how we cover Salesforce topics before you decide.
🔗 Enroll now: salesforceandi...
🚀 Level Up Your Salesforce Skills! 🚀
Sign up for my Salesforce Interview Prep Course and get:
1⃣ Access to All Recordings: Covering all the important Salesforce topics.
2⃣ Mock Interviews: Practice and get better at interviews.
3⃣ Community Support: Get your doubts answered anytime by our awesome community.
4⃣ Resume Review: Personalized feedback to make your resume stand out.
5⃣ 1:1 Career Advice: Chat with me directly about those tough career decisions.
6⃣ Weekend Doubt Sessions: Join live Q&A sessions to clear up any confusion.
7⃣ Helpful Notes: Quick and easy reference for your studies.
💥 All of this for just ₹499, the lowest price ever! Plus, you can check out the free preview to see how we cover Salesforce topics before you decide.
🔗 Enroll now: salesforceandinterviews.graphy.com/
Hii , great explanation . Are you providing any opportunities for experience candidate.
my group have more experienced people than freshers :)
Can this be done by flow?
yes
100 % percent, in fact I want people to try this with flow.
Hi Sir ,How can I join your Interview preparation batch.
you can join the recorded session for now - 🚀 Level Up Your Salesforce Skills! 🚀
Sign up for my Salesforce Interview Prep Course and get:
1⃣ Access to All Recordings: Covering all the important Salesforce topics.
2⃣ Mock Interviews: Practice and get better at interviews.
3⃣ Community Support: Get your doubts answered anytime by our awesome community.
4⃣ Resume Review: Personalized feedback to make your resume stand out.
5⃣ 1:1 Career Advice: Chat with me directly about those tough career decisions.
6⃣ Weekend Doubt Sessions: Join live Q&A sessions to clear up any confusion.
7⃣ Helpful Notes: Quick and easy reference for your studies.
💥 All of this for just ₹499, the lowest price ever! Plus, you can check out the free preview to see how we cover Salesforce topics before you decide.
🔗 Enroll now: salesforceandinterviews.graphy.com/
very nice explanation
Thank you :)
I modified little bit and included after delete event also
trigger CountOfOLIonAcc on OpportunityLineItem (after insert,after delete ) {
Set oppIds = new Set();
Set accIds = new Set();
List newoplineList = new List();
newoplineList = (Trigger.isInsert? Trigger.New : Trigger.Old);
for(OpportunityLineItem op :newoplineList)
oppIds.add(op.OpportunityId);
for(Opportunity op :[Select AccountId , id from Opportunity WHERE Id IN :oppIds ])
accIds.add(op.AccountId);
List aggroliList = [SELECT Opportunity.AccountId acId, count(id) oliCnt FROM OpportunityLineItem
WHERE Opportunity.AccountId IN :accIds group by Opportunity.AccountId];
Map OLIcnt = new Map();
for( AggregateResult oli : aggroliList)
{
OLIcnt.put( (Id)oli.get('acId'), (Integer)oli.get('oliCnt') );
}
List newUpAccList = new List();
for(Id accId:accIds){
Account ac = new Account(Id = accId);
if(OLIcnt.containsKey(ac.Id))
ac.Count_OLI__c = OLIcnt.get(ac.Id);
newUpAccList.add(ac);
}
update newUpAccList;
}
well done
❤ Awesome sir
Thanks Deep 🙏