-
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
Provide the right solution | Salesforce & Tableau Integration
Imagine having an advantage that lets you understand your customers better than ever before. That's exactly what happens when you combine the might of Salesforce…
Comprehensive Salesforce Managed Services for Growing Businesses
As businesses grow, so do their challenges. One of the critical aspects of scaling any organization is managing the complexity that comes with it. Salesforce,…
Time for Your Salesforce Checkup
When was the last time you had the annual checkup? What about a Salesforce Checkup? Maybe it has been a few years since your company…
Popular Salesforce Videos
How Can Salesforce Marketing Cloud Help You Grow Your Business Exponentially?
Salesforce Marketing Cloud can help you take your marketing to the next level by providing an all-in-one platform that helps you strategize across multiple channels.…
Process Builder In Salesforce | Tutorial Video
Do you want to create a record for any object from a workflow? Do you want to call your Apex class from a workflow? Do…
360 SMS App Demo
360 SMS App is considered to be the most reliable Salesforce SMS App. This App is listed on the AppExchange from the name "360 SMS…