+ 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