function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rstanbaurstanbau 

Overwrite Opportunity Amount

Hi - I'm trying to write code to overwrite Opportunity.Amount with a value caluclated in a calculated field.  I've tried a couple of differnt approaches, but am stumped.

 

My latest attempt was to write a class with a method that copied the value in a user-defined field to the opportunity.amount field  when the record was saved.  I also tried writing similar code that updates one or more selected records and is executed on a button is clicked from a list page.  This apporach, like the others that I have tried, resulted in an error saying that opportunity.amount is a read-only field.

 

I'm stumped.

 

I've had no problem updating and manipulating other standard object fields.  The Oppportunity.Amount field is an important one to contain meaningful data, as it is referenced by SF forecasting and Campaigns.  So far, I am not able to put the values in this field that I would like it to contain. 

 

I would really appreciate any guidance that is provided about how I can achieve this (or if it is hopeless - which I cannot believe).

 

Thank you!

Rich

 

Best Answer chosen by Admin (Salesforce Developers) 
cvjcvj

Are you using products?

 

For opportunities with products, the amount is the sum of the related products. You cannot directly edit the amount unless the opportunity has no products. To change the amount for an opportunity that contains products, edit the sales price or quantity of the related products.