You need to sign in to do that
Don't have an account?
abhishek singh 497
to compare old and new value of formula field in apex trigger
Hello Team,
I have one requirement where I need to compare old and new value of formula field in apex trigger.
Anyone has any suggestions or code please let me know.
Thanks
I have one requirement where I need to compare old and new value of formula field in apex trigger.
Anyone has any suggestions or code please let me know.
Thanks
In this example we have created two number fields and one formula field to store the total of number field 1 and number field 2
Old set is 10+12= 22 and the new set is 12+12 = 24, Total is the formula field which adds Number1 and Number2
So, the old value of formula field is 22 and the new value is 24. The same can be found in the logs
Trigger code goes here: Modify the code based on your requirement. Share the results here.
Team codegine!
No, you cannot compare two formula field values in Apex triggers as it will not bring any changes after trigger execution as you are trying to compare fields that are of formula type.
Please go through the helpful links provided below:
https://salesforce.stackexchange.com/questions/8100/do-apex-triggers-have-access-to-formula-fields
https://success.salesforce.com/answers?id=9063A000000p6rrQAA
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
I missed one thing in my question , I need to run trigger also on basis of formula field.