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.
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.
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
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