-
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
What is Salesforce Community Cloud?
Originally named ‘Salesforce Customer and Partner Portals’, Community Cloud is among the most popular cloud options from Salesforce. As with the rest of the platform,…
What is the Content Security Policy (CSP) in Salesforce in 2023?
This is a set of guidelines for securing websites that developers and system administrators may use. Clickjacking, cross-site scripting (XSS), and other code injection attacks…
Top Salesforce Winter '22 Release Features
Salesforce has three big releases coming out each year to make it more user-friendly. Each new release is loaded with features. These features help the…
Popular Salesforce Videos
Salesforce Platform Quick Tip: How to Make Key Information Easier to Find
Want to flag things on a Salesforce record, so that your users notice? Like flagging a super important customer record, or alerting them that a…
Salesforce Service Cloud Voice Demo
Salesforce Service Cloud Voice uses intelligent telephony to increase agent productivity and better serve customers, from anywhere. Today, customers can connect with companies across almost…
Build a Discount Approval Process | Step by Step Guide | Trailhead Project
Building a robust discount approval process is the first step in getting a grip of price discounts that are eating into profit. In this video…