I had the need for a formula field in Salesforce.com to do two things:
- Evaluate an expression that my user types in. example: ((2+2) * 6) / 3
- Store the actual formula the user typed in to another field, in the case the formula should be audited for accuracy.
The formula is different for every record (being used on the Contract standard object), thus the need for my user to type it in. Plus, I have to be able include the actual formula in a Report column for auditors.
I solved this using a few things:
- Two custom fields:”FieldX__c” for the custom expression and “FieldY__c” for the evaluation
- Javacript to conduct the calculation
- A visualforce page to put the two fields and javascript together