-
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
CTI Integration with Salesforce and Its Benefits
Now, when we are aware of the system of CRM, i.e. Customer Relationship Management, there is one other system as well, known as CTI. The…
Delivering Superior Customer Service with Salesforce in Digital Lending
Digital Lending is a process where financial institutions offer loans and other lines of credit digitally, without the need for face-to-face interaction. This can be…
Top 10 Benefits of Salesforce CPQ for Your Business
Getting a lead to enter into your sales process is a great challenge, but it is an even greater challenge to make sure that they…
Popular Salesforce Videos
Password Protect Records in Salesforce
Suppose Salesforce org record level access is set to Public Read Only and now business want to restrict few records visible to only those users…
How Salesforce is Paving The Way To Greater Digital Transformation
Digital transformation success is often a question of speed & implementation. Companies know how important technology is to their business, but can they evolve and…
How To Start A Career In Salesforce? | Video Tutorial
Planning to start a career in Salesforce? Wondering where to head and learn. Watch this video and join this useful group for Salesforce job &…