-
What to do if Salesforce Trigger is not working as expected?
I have a trigger on release(Child of Opportunity) record. The logic for the trigger is in the handler class. I am updating checkbox to true on Opportunity(Parent) whenever release record edited or inserted. The default value for checkbox needs be false and if any record inserted/updated on release object has Release__c.Test__c value starts with other than '14%' then checkbox needs to set to False. I mean to say checkbox will be set to true only when all record has Test__c = '14%' else set to false. I tested my trigger logic but it is not working as expected also with my logic some time I get Maximum CPU error. Any help or suggestion?
trigger updateCheckbocOpp on Release__c (after insert, after update) { list<Release__c> bqList = new list<Release__c>(); for (Release__c childObj : Trigger.new){ listIds.add(childObj.Opportunity__c); } oppsToUpdate = new Map<Id, Opportunity>([SELECT id, Set_Rel__c,(SELECT ID,Test__c FROM Plan_Sum__r) FROM Opportunity WHERE ID IN :listIds]); system.debug('testing trigger >> ' + oppsToUpdate); for (Opportunity opp: oppsToUpdate.values()){ for(Release__c bq :opp.Plan_Sum__r){ system.debug('Release Record >> '+bq); opp.Set_Rel__c = true; if(!bq.Test__c.startsWith('14%')){ opp.Set_Rel__c = false; } } } system.debug('Update >>>' + oppsToUpdate.values()); update oppsToUpdate.values(); }
Log In to reply.
Popular Salesforce Blogs
Expand Your Business With Salesforce Contact Center
Salesforce Contact Center is a cloud-based customer service solution that enables businesses to deliver an exceptional customer experience. The solution provides a complete set of…
Experience Salesforce Customization Services With Experts
CRM, or customer relationship management, is an application that tries to manage all relationships and interactions with customers and prospective customers in any business. A…
Stages of Salesforce CPQ Implementation
Your organization needs to work smart to stay ahead of its competition, and one way to obtain this is with CPQ software. With Salesforce CPQ…
Popular Salesforce Videos
Makes Migration Between Salesforce Org Easy Using BOFC Application
BOFC has empowered global organizations by simplifying one of the biggest challenges in Salesforce migration, i.e., metadata management. In the above one got to know…
How to Become a Salesforce Admin | 6-step Guide
Salesforce administrators are the backbone of any company that uses Salesforce. They are responsible for maintaining the Salesforce platform to ensure it meets the needs…
How to Create a Salesforce Object Calendar
In this video, we show you how to create a calendar view for any object in Salesforce. This is a feature that can easily help…