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

How to detect changes in formula field value?



I am trying to figure out a way through which I could trigger a workflow based on the value contained inside a formula field. I obviously can create a normal workflow, but that would allow me only to check the value at the instance when a record is created or edited. Is there any way of doing it EVERY time the value of a particular field changes?


Look forward to some encouraging solutions.







As of now, I could think of doing by Apex Triggers. Below is the sample code:


trigger CheckFormual on Account (before insert, before update) 
if(system.trigger.OldMap.get(a.Id).FormulaFeild__c != system.trigger.NewMap.get(a.Id).FormulaFeild__c)
a.AnotherFeild__c = a.FormulaFeild__c;


In the above code, whenever there is a change in the formula feild I am populating that value to another feild. Likewise you can track.



Hope this helps.




hi sureka,



could you please help me to write the test class for this trigger. thanks