-
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
Making Shift from Salesforce Classic to Lightning – Must Needed Steps to Follow
Salesforce has rolled out its next-gen UI ‘Lightning‘ in 2014. The Lightning platform delivers reimagined user experience to enable fast & seamless app development. Enterprises…
Learn All About Salesforce Managed Services vs In-house Team
The day-to-day operations of modern businesses depend on technology and cloud-based tools. With ever-changing IT needs and business configuration tools becoming more important, one small…
Salesforce Sales Cloud and Service Cloud: A Successful Binomial
Sales Cloud and Service Cloud are two of the most used Salesforce products. Do you know what each of them consists of? Here you can…
Popular Salesforce Videos
Maximizing Salesforce Lightning Experience and Lightning Component Performance
00:04:57 - Agenda 00:06:08 - Difference between Salesforce Classic and Salesforce Lightning 00:17:45 - Demo: Load time comparison between Salesforce Classic and Salesforce Lightning when…
The 3 Most Common Challenges Associated With B2b Commerce Cloud Implementations
With growing technology businesses are adapting to the new changes. B2B commerce cloud is one of them. But to implement the B2B commerce cloud is…
Write Tableau CRM Data to Salesforce Objects
Leverage the power of fully native analytics in your CRM workflows with Tableau CRM. Salesforce CRM users can work more efficiently, spot trends, predict outcomes,…