-
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
Is Salesforce CRM the Best Choice for Your Business? Pros &Amp; Cons
Customers are the heartbeat of any business. How effectively you onboard them, manage their relationships, and deliver the solutions they need plays a pivotal role…
Communicate Between Components Using Events in Lightning Web Components | Salesforce Developer Guide
Introduction Standard DOM events are dispatched by Lightning web components. Custom events may also be generated and dispatched by components. To communicate the components holding…
Everything You Need To Know About Salesforce Sales Enablement
Sales representatives can quickly onboard with the aid of sales enablement. Additionally, it enhances their overall sales abilities and supports them in effectively managing business…
Popular Salesforce Videos
How to Set Up Salesforce Knowledge?
Watch this video to learn how to set up Salesforce Knowledge so you can help your team more easily find answers to common customer requests.…
Salesforce Training Videos For Beginners - 3 | Salesforce Admin Training
This Salesforce Training Video will help us in quotation generation and improve customer communication. Generating proposals can be a drag on sales team productivity. Editing…
Sharing and Visibility With Salesforce
Watch this amazing to understand the Salesforce sharing model, and how to structure profiles, roles, and sharing rules to control visibility. Do let us know…