-
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
How to Install Service Setup in the Salesforce Service Cloud
When I started to implement Salesforce einstein Bots for the first time, I found difficult to understand the flow behind it and various channels involved.…
What Are Salesforce Development And Integration Services?
Salesforce Development Services and integration solutions are redefining the way organizations achieve agility, efficiency, and scalability in today’s digitally driven marketplace. As technology advances and…
Salesforce Integration with OpenAI : Revolutionizing Image Generation
Hey Guys, today we are discussing DALL-E (which is a product of openAI) and Salesforce Integration (Salesforce Integration with OpenAI). DALL·E is designed to generate coherent…
Popular Salesforce Videos
Apex Design Patterns : The Singleton Pattern in Salesforce || #Salesforce #DesignPatterns
The Singleton Pattern One Private variable of the class itself will hold the instance of the complete class so that we can access all the…
Salesforce Talent Alliance Demo
Salesforce Talent Alliance connects employers to Salesforce candidates and brings new talent into the ecosystem, emphasizing building a diverse workforce that reflects society around the…
Introduction to Report and Dashboard in Salesforce | Salesforce Training Videos
A report is a list of records that meet the criteria you define. It's displayed in Salesforce in rows and columns, and can be filtered,…