💻 Join the Titan Community : Discover Exclusive Insights on LinkedIn / mycompany 💻 Explore the Power of Titan : Visit Our Official Website Now 🔗 titandxp.com/
Пікірлер: 9
@goldylodhi211620 күн бұрын
Thanks sir ❤ nice explanation
@adityasinghbisen421520 күн бұрын
the trigger will run every time the record is updated when the amount is more than 10k , we should have checked if the values has changed and then only allow the logic to run.
@crazyvlogs236616 күн бұрын
Hi whenever u create a video on trigger scenarios which are asked in real time interviews please make sure that u must inform the experience level. I hope you follow it.
@sfdcninjasКүн бұрын
Sure i will follow it but sometimes people just comment about the scenario and company in which it is asked not the experience.
@parthipan034519 күн бұрын
Can we do soql query directly ownerid owner.name from opportunity instead of using map and query on user. Right .?
@kumareshghosh559320 күн бұрын
You did not differentiate the update operation where every time the amount gets 10000 , trigger will run, but it should check previous oldMap value and then send mail I guess, however using map was not necessary for user there so I implemented my code: public with sharing class amountOwnerHandler { //if any opportunity is created or updated and amount is greater than 10000,then send an email to the record owner regarding the DML operation. public static void afterOperation(List newOpps, Map oldMapOpps){ set ownerIds=new Set(); for(opportunity opps:newOpps){ //for insert if(opps.amount!=null && opps.amount>=10000 && oldMapOpps==null){ ownerIds.add(opps.OwnerId); } //for update if(opps.amount!=null && oldMapOpps!=null && opps.amount>=10000 && oldMapOpps.get(opps.id).amount
@nikhilvadithala20 күн бұрын
Can you provide solution for below scenario Asked in accenture interview Opportunity has a relationship with child object opportunity line item When ever opportunity stage is updated as closed/won The status/ any text field on most recently modified child record should be updated as approved And for remaining records field should be updated as rejected In case the opportunity stage is updated as closed/lost Most recent child record status should be updated as lost and remaining child records should be updated as rejected
@user-pc2tf7im5b19 күн бұрын
Hey @nikhilvadithala, Try this approach and let me know, if you face any difficulty in understanding code. Set oppIds = new Set(); for (Opportunity op : newOpps) { if ( (op.StageName == 'Closed Won' || op.StageName == 'Closed Lost') && (oldOpps.get(op.Id).StageName != op.StageName) ) { oppIds.add(op.Id); } } if (oppIds.size() > 0) { List oppList = [SELECT Id, StageName, (SELECT Id, Description FROM OpportunityLineItems ORDER BY LastModifiedDate DESC) FROM Opportunity WHERE Id IN :oppIds]; List oppLineItemList = new List(); if (oppList.size() > 0) { for (Opportunity op : oppList) { if (op.OpportunityLineItems.size() > 0) { for (Integer i = 0; i < op.OpportunityLineItems.size(); i++) { if (op.StageName == 'Closed Won') { op.OpportunityLineItems[i].Description = (i == 0) ? 'Approved' : 'Rejected'; oppLineItemList.add(op.OpportunityLineItems[i]); } else if (op.StageName == 'Closed Lost') { op.OpportunityLineItems[i].Description = (i == 0) ? 'Lost' : 'Rejected'; oppLineItemList.add(op.OpportunityLineItems[i]); } } } } } if (oppLineItemList.size() > 0) { try { update oppLineItemList; } catch (Exception e) { System.debug('Error while updatation!'+e); } } }