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

Need help with a Trigger

Hi all,


I am trying to create a formula, but it is not working for the problem that I have.  I am just starting to learn about triggers and need some help with one.


The fields called "Forecast Category" and "Stage" on the Opportunity page, are the two fields I am using.


I am trying to override the auto update of the Forecast Category when I change the Opportunity stage.


Forecast Field = Committed

Stage = Proposal


If the Stage is changed from Proposal to Contract, the system auto updates the Forecast to "Upside". 


On Save = I would like for the Forecast to stay as "Committed", but only if the prior Stage was "Proposal" and the Forecast was "Committed".



I hope that makes sense.  Any help would be greatly appreciated!






Best Answer chosen by Admin (Salesforce Developers) 

I figured it out, but now I cannot deploy it.  Anyone have a how to guide on deploying triggers into



Update Forecast field to Committed.

trigger ForecastUpdate on Opportunity (before update) {

/*Loop every new location you enter*/
for(Opportunity {
Opportunity oldopp = trigger.old[0];

if(l.StageName=='Contract' && l.ForecastCategoryName=='Upside' &&
oldopp.StageName=='Proposal' && oldopp.ForecastCategoryName=='Committed'){