-
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 Imported for Business Accounts and Contacts?
REQUIRED EDITIONS Accessible in: Salesforce Classic (not accessible in all organizations) and Lightning Experience Accessible in: All Editions, with the exception of Database.com Organization import…

The Benefits of Outsourcing Salesforce Support Services
Outsourcing Salesforce support services can offer numerous advantages for businesses looking to optimize their Salesforce investment without the burden of managing an in-house team. By…

How to Build a Legendary Partnership with Salesforce Partner Portal in 2023?
Are you ready to take your business/partnership to the next level? Whether you’re a small startup or a well-established enterprise, the Salesforce Partner Portal can…
Popular Salesforce Videos
What is Salesforce Roles? Explain in Details
Salesforce Roles deals with the hierarchy of your organizations, So it will actually be based on the record level access and it can override the…
How to Create Contact in Salesforce | Salesforce Contacts | Salesforce Tutorial
Contact in Salesforce represents the individual people associated with the business accounts in your organization or Contact records are used for individuals to store personal…
What is Validation Rule in Salesforce?
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A…