-
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
Illustrations in Salesforce Lightning Experience
An illustration is an image or a diagram that helps make something clear. Inline texts work with illustrations to communicate a state in a more…
How to Whitelist All IPs in Salesforce?
In the Network Access under Security Controls you might have seen this: "The list below contains IP address ranges from sources that your organization trusts.…
Salesforce: The Customer Success Platform To Grow Your Business Automation
If you’ve ever thought how great it would be to have a personal assistant, you should consider exploring Salesforce and its automation features. Imagine having…
Popular Salesforce Videos
How To Use RingCentral App In Salesforce | Salesforce Service Cloud
Learn how to use RingCentral App in Salesforce. This video will cover the following points - 1. Advantages Take a look at the advantages of…
How to Establish a Many to Many Relationship in Salesforce?
You can use master-detail relationships to model many-to-many relationships between any two objects. A many-to-many relationship allows each record of one object to be linked…
Driving Gamified Interactions on Salesforce Communities With ScoreNotch | Use-Cases
A Salesforce-native, Lightning-ready solution, ScoreNotch enables you to dynamically gamify Salesforce communities. Watch this video to learn more about its use-cases. For more, please visit…