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
NongNong 

How to capture field changing in Trigger

Dear All,

 

I am just the beginner on the APEX and I have the problem as I don't know the APEX code in Trigger to capture if user has changed field Stage in Opportunities or not .

 

Could you please advise  and thank you very much in advance for you help.

 

Regards

Anong

 

 

Best Answer chosen by Admin (Salesforce Developers) 
hisrinuhisrinu

You can use

 

for(Opportunity o : Trigger.New){

if(Trigger.oldmap.get(o.id).Stagename != o.stagename){

//write your code

}

}

All Answers

hisrinuhisrinu

You can use

 

for(Opportunity o : Trigger.New){

if(Trigger.oldmap.get(o.id).Stagename != o.stagename){

//write your code

}

}

This was selected as the best answer
NongNong

Dear Srini,

 

Thank you very much for your help, it works!

 

Best Regards

Anong