-
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
![](https://images.forcetalks.com/wp-content/uploads/2016/04/25085344/Lightning-Design-Experience-In-Visualforce-Pages-with-Lightning-CSS-Framework.jpg)
Lightning Design Experience In Visualforce Pages with Lightning CSS Framework
Salesforce Lighting Design System(SLDS) is a CSS framework introduced by Salesforce to create faster,responsive and beautiful pages even in Salesforce Classic. This css framework is…
![](https://images.forcetalks.com/wp-content/uploads/2024/04/30102411/sa_1714472577Boutique-1024x576.jpg)
Why Do You Need Salesforce CRM Support in 2024?
In the fast-paced world of business, nurturing strong relationships with customers is the cornerstone of success. That's where Customer Relationship Management (CRM) platforms like Salesforce…
![](https://images.forcetalks.com/wp-content/uploads/2024/01/18110444/sa_1705575874001jpg-1024x576.jpg)
Optimising Salesforce-Kakao for Cross-Border Sales Success
In the rapidly evolving realm of worldwide trade, companies are always searching for inventive approaches to surmount cross-border obstacles and propel revenue growth. This is…
Popular Salesforce Videos
Dreamforce 2019 - An Overview!
Salesforce Dreamforce2019 is scheduled for November 19-22 in San Francisco, California at the Moscone Center. #Dreamforce is one of the largest cloud and SaaS-centric conferences…
Top 3 Things to See at Dreamforce 2021 | Salesforce
Three things you definitely don't want to miss at Dreamforce this year? 👆 #DF21 is packed with tons of educational content about your fave Salesforce…
Creation Of Validation Rules And Verifying Them In Salesforce
Learn how to create and verify validation rules in Salesforce. This video will cover the following points - 1. Introduction Get a brief introduction about…