You need to sign in to do that
Don't have an account?
MMA_FORCE
Update Amount Field in Salesforce via Trigger
Hi,
I have written this code to update Amount Field on Opportunity via trigger. The issue is I can see in the debug log that it is doing it correctly but on the opportunity the amount field does not change at all...
Its weird.... Any thoughts?
Thanks
Z
I have written this code to update Amount Field on Opportunity via trigger. The issue is I can see in the debug log that it is doing it correctly but on the opportunity the amount field does not change at all...
trigger Update_amount on Opportunity (before insert,before update) { for (opportunity obj: trigger.new){ obj.Amount = (obj.Total_Value__c*12)+ obj.Amount; System.Debug('x'+ obj.Amount); System.Debug('y'+ obj.Total_Value__c); System.Debug('z'+ obj.Total_Value__c*12); } }
Its weird.... Any thoughts?
Thanks
Z
You can't update Opportunity Amount field if that opportunity contains lineitem. this is documented at Salesforce which says:
"Estimated total sale amount. For opportunities with products, the amount is the sum of the related products. Any attempt to update this field, if the record has products, will be ignored. The update call will not be rejected, and other fields will be updated as specified, but the Amount will be unchanged."
Please check Amount field description
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_opportunity.htm
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer.