-
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
Ultimate Guide: How to Import Your Salesforce Metadata into AbstraLinx
In the dynamic landscape of data management, the need for efficient and user-friendly tools has never been more critical. This article unveils AbstraLinx, a specialized…
How do I Choose a Salesforce Implementation Partner?
Hey there! If you’re reading this, chances are you’re looking to take your business to the next level with Salesforce. That’s a fantastic move! Salesforce…
Popular Salesforce Videos
How to Set Up Salesforce Essentials
Watch through to the end for a quick link to our Hands-on Workshops and Training. Watch this video for step-by-step instructions on how to get…
Salsa Engage Reports and Dashboards: Mission focused Data Visualization
A Salsa Engage integration with Salesforce gives you comprehensive reports and high-performance dashboards and helps you to optimize your fundraising goals and retain supporters. Get…
Salesforce Development Tutorial - sObjects
It is very easy to learn Salesforce with the world class training tutorial. Training is key for the right knowledge. Those who work as an…