You need to sign in to do that
Don't have an account?
AkashGarg555
before insert trigger is not working
I have a requirement where CustomerSuccess__c field on opportunity to be updated 'true' if CustomerSuccess__c field on Account is 'true' in before Insert event.
I have tried below solution, trigger saved succesfully but it didn't work.
Can anyone explain why my trigger is not working
Akash
I have tried below solution, trigger saved succesfully but it didn't work.
Can anyone explain why my trigger is not working
trigger OppoCustomerSuccessCheckboxUpdate on Opportunity (before insert) { for(Opportunity opp : Trigger.New) { if(Opp.AccountID != null) { if(Opp.Account.CustomerSuccess__c) { Opp.CustomerSuccess__c = true; } } } }Regards,
Akash
Try this code.kindly modify according to your requirement
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
All Answers
Can you just debug below line of your code:-
if(Opp.Account.CustomerSuccess__c) and let me know what value it is returning.
Regards,
Abhishek Singh.
It is returning false in debugging but i have checked CustomerSuccess__c field on Account is checked(true).
Why it is returning FALSE, can you help me on understanding this.
Regards,
Akash
Try this code.kindly modify according to your requirement
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
There is a concept that trigger will not execute based on the condition of lookup object field like in your case.
if(Opp.Account.CustomerSuccess__c) ===> this will not work.
if(opp.Accountid!=null) ====> this will work.
You can take help of Devi's trigger,it is correct.
Thanks.
Abhishek Singh.
You cannot access opp.account.anything
You need to query the data, put in a map and then look up the info in the loop
@Devi Chandrika - Your code works perfectly.
Closing this ticket.