Friday, November 2, 2012

Custom Formula Fields in Force.com

The general fields store values entered by users. There are times we want to apply calculation on these values and come up with the result. Formula fields in Force.com platform does the exact same thing.  Formula fields are nothing but the calculated fields. In other words, you apply a formula on the fields that store data. This calculates the required value and returns the result without changing the underlying data.

Force.com platform provides all required operators including logical operators and many functions to perform our calculations. Go ahead and try it out.

Add a new custom field and select 'Formula' for Data Type. Continue with the next step, enter the usual Field Label and Name, also select the Return Type. Return type is the type of the result you are expecting from your calculation. Move on to next step, switch to 'Advanced Formula' tab and this is where all the fun starts. 

There is an editor where you come up with your calculated field or custom formula field. Platform provides you with 4 different options to help you out.

Insert Field - This button provides the list of data storing fields that you could use in your formula.

Insert Operator - This button provides all the operators that platform provides.

Functions - Scroll down this list and see the number of functions you have to come up with your formula. Click on the function and a quick helper text is displayed about the selected function.

Check Syntax - At the bottom of the editor, there is a button called 'Check Syntax'. When you have your formula ready, you don't have to store it without knowing whether it is syntactically correct. Use this 'Check Syntax' button and this will validate your formula.

That is it! With the help of these 4 options you can write a simple or complex formula, validate    and store it as a Formula Field.

Happy cloud computing using Salesforce!

No comments:

Post a Comment