You are on page 1of 4

Formula Fields:

===============
Formula Fields are the ReadOnly System Generated Fields, Whose value will be
generating by Salesforce Automatically based on the specified formula.

Formula fields are not editable by the users. An object can have one or more
formula fields.

While Creating the field inside the object, we have to select the DataType as
"Formula". And while Creating the field, we have to specify the Formula /
Expression to be used to Calculate the value in the field.

Salesforce provides a set of readymade functions to be used to prepare the formula.

Functions:
----------
1. Abs(Number):
- This function returns the Absolute value of the specified number.

Ex: Abs(-45.345) --> O/p: 45.345


Abs(456.90) --> O/p: 456.90

2. Sqrt(Number):
It returns the square root value of the given number.
Ex:
sqrt(144) --> O/p: 12

3. Len(string):
It returns an integer value, which indicate the number of characters exist in
the specified string. (Spaces also counted as a character)

Ex:
Len('Welcome To Hyderabad') --> O/p: 20
Len('Welcome') --> O/p: 7

4. Trim():
It removes the blank spaces exist before/ after the specified string.

Ex:
' Welcome '

5. Upper(string):
It converts all the character exist in the string into upper case letters.

Ex:
Upper('welcome') --> O/p: WELCOME.

6. Lower(string)
It converts all the characters exist in the string into Lower case letters.

Ex:
Lower('WELCOME') --> O/p: welcome.

7. Floor(number):
It returns the nearest lower value of the given number.

Ex:
Floor(14.1) --> 14
8. Ceiling(Number):
It returns the nearest higher value of the given number.

9. Left(string,<Number Of Characters>):
It returns the specified number of characters from the Left side of the
string.

Ex:
Left('Welcome',3) --> O/p: Wel

10. Right(string,<Number Of Characters>):


It returns the specified number of characters from the Right side of the
string.

Ex:
Right('Welcome',3) --> O/p: ome

11. Substring(string, <Integer startingPosition>, <Integer NumberOfCharacters>):


It returns the specified number of characters getting from the specified
starting position in the string.

Ex:
Substring('Welcome to Hyderabad',4,5) --> O/p: 'come '

12. Today():
- It returns the Today's system date. (mm/dd/yyyy)

Ex: Today() --> 06/26/2016

13. Year(Date):
This function will returns the "Year" portion of the specified date.

Ex: Year(Today()) --> O/p: 2016

14. Month(Date):
This function returns the month value of the specified date.

Ex: Month(Today()) --> O/p: 06

15. Day(Date):
This function returns Date value of the specified date.

Ex: Day(Today()) --> O/p: 26

16. If(<Conditions> , <True>,<False>):


If is a conditional statement, which evaluates all the specified conditions
and returns TRUE, If all the conditions satisfied.
Else it returns FALSE.

17. Image(<Path Of the Image>,


Alternate Text
[,Height, Width]
)

By using this function, we can display the images dynamically at time in the
record detailed page.

18. Case( <Expression> ,


<Case1>,<value1>,
<Case2>,<Value2>,
<Case3>,<Value3>,
....
...
<CaseN>,<ValueN>,
<default Value>
)

19. Text(<PicklistFieldName>):
Text function will returns the Currently Selected value from the specified
picklist field.

Note:
While Creating the Formula Field, we have the Select the DataType as
"Formula". Upon Creating the field, we have to specify the "Formula / Expression",
to be used to prepare the value for the field.

Formula Result can be any one of the below 8 types.

1. Currency
2. Number
3. Percent
4. CheckBox
5. Text Type
6. Date
7. Time
8. DateTime

Navigation:
Click on the Required Object's Tab (Ex: Accounts)
1. Click on "View Fields" link.
2. Goto the "Custom Fields & Relationships" section.
3. Click on "New" button.
4. Select the DataType as "Formula".
5. Click on "Next" button.
6. Enter the Formula Field Name, and Description.
7. Select the Formula Return Type. (Ex: Currency)
8. Click on "Next" button.
9. Enter the Formula Conditions inside the Formula Editor.
10. Click on "Check Syntax" button.
11. Click on "Next" button.
12. Select the "Visible" CheckBox, to make the Field to be visible to
all
profile users.
13. Click on "Next" button.
14. Click on "Save" button.

UseCase:
========
Create a Formula Field on the Account Object, to Calculate the 5% of Service
Tax based on the Annual Revenue.

Formula Return Type : Currency


Formula Condition: AnnualRevenue * 5 / 100

Note: We can Change the Formula field values by changing the Source Field Value.

UseCase:
========
Create a Formula Field on the Account Object, to Calculate the Net Annual
Revenue (After All Deductions)

Formula Return Type : Currency


Formula Condition: AnnualRevenue - Service_Tax_Amount__C

Note: We can reference One Formula Field inside an another Formula Field.

UseCase:
========
Create a Cross-Object Formula field, to represent the Parent Account Record's
Annual Revenue value into the Related Child Contact Records.

Formula Return Type : Currency


Formula Condition: Account.AnnualRevenue

You might also like