-
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

Salesforce Org Migration to Hyperforce
What is Org Migration? In order to arrange for our customers' continuing growth, we have a tendency to sometimes ought to perform associate degree activity…

Why MuleSoft is the Perfect Integration Platform for Your Business?
Organizations integrate their business applications primarily to expand their business operations and reach their customers quickly. But integration doesn't just involve the systems and services;…

Benefits of Salesforce for FinTech: Boosting Efficiency and Scaling Growth
In recent years, the FinTech industry has boomed and transformed how people manage money, invest, and access financial products. However, with this growth, FinTech organizations…
Popular Salesforce Videos
Creating a Roll-up Using DLRS | Salesforce Tutorial Video
In certain situations, an object does not support a roll-up or the relation is not permitted. Learn how to make it possible by using the…
Salesforce Financial Services Cloud demo
Today's seamlessly connected customer is raising expectations for organizations to "show them they know them" by providing efficient, informed and integrated experiences no matter which…
Salesforce Lightning Development Tutorial - Lightning Components in Visualforce
Salesforce Lightning Custom Component Development Tutorial for Beginners Learn how to embed lightning components in a Visualforce page. 3 Steps Add apex:includeLightning tag in your…