+ Start a Discussion
Chaudhary AdityaChaudhary Aditya 

Architecture/Thought Pattern on Updates within Triggers: Errors on Web Screen vs Bulk update.

Description:  A 'before update' trigger on Opportunity. Trigger logic has some validations/consitions.

Completed Tasks: 
1.Trigger has been written.
2. All Errored Out Opportunity Id are stored in a map called: erorredOutOpportunityMap
3. Error on screen is displayed using: 
    webpageOpp.addError('Error Message');     

Help on
Best way to handle: 
(a) Show error to user (in browser) if record cannot be updated for some reason. e.g. A validation in trigger fails. 
(b) For bulk updates -  Skip over the ones that failed and update the rest. [Notify/Add to Queue for the missed Opportunities]. 



I would like to believe this is a relatively common use case in Salesforce applications. 

Is it a good industry practice to add errored out Opportunities to a queue and have a human look at it? 

I would really appreciate a pointer/steps/improvement & errors in above.



        
 





 
Naveen Nelavelli 9Naveen Nelavelli 9
Hi Aditya,
for bulk updates- rather than skipping failed opportunities ,you should log them to error log custom object in org  or you should have a column on opportunity to capture errors.Most of the  errors need data correction by Business ,so you can share error log reports to business.