You need to sign in to do that
Don't have an account?

old and new vales in apex class
Hi
I am trying to understand how to compare old values and new values for sobject.
I have a opportunity custom field , type=check box, which is checked only when stageName='Closed Won'.
when the custom field is checked the trigger further will do some business logic.
any help will ge greatly apprecitaed.
thanks
I am trying to understand how to compare old values and new values for sobject.
I have a opportunity custom field , type=check box, which is checked only when stageName='Closed Won'.
when the custom field is checked the trigger further will do some business logic.
any help will ge greatly apprecitaed.
thanks
In trigger, values are stored in global variables.
old values => Trigger.oldMap
new value => Trigger.new
Here is a sample:
All Answers
In trigger, values are stored in global variables.
old values => Trigger.oldMap
new value => Trigger.new
Here is a sample:
How to get trigger.old Map in apex class not in trigger?
Thanks
vandana
this is what I did.could you pls tell me where I went wrong becuase the field isDifference is not updating
thanks
vandana
The issue was I was comparing the new version with the new version only
Boolean oldOppIsWon = o1.StageName.equals('Closed Won');
Boolean newOppIsWon = o1.StageName.equals('Closed Won');
so I changed as follows:
Boolean oldOppIsWon = o1.StageName.equals('Closed Won');
Boolean newOppIsWon = o.StageName.equals('Closed Won');
it is good to see you are progressing on your own!
is everything okay now? or you still have some clarifications?
good to see your post.
sorry for the delay in replying
I got the logic working.thanks
vandana