Salesforce Developer Formula Fields


// Salesforce - Developer - Creating a New Formula Field:

You’ve got a lot of data in your organization. Your users need to access and 
understand this data at-a-glance without doing a bunch of calculations in their 
heads. Enter formula fields, the powerful tool that gives you control of how 
your data is displayed.

Let’s say you wanted to take two numeric fields on a record and divide them to 
create a percentage. Or perhaps you want to turn a field into a clickable 
hyperlink for easy access to important information from a record’s page layout. 
Maybe you want to take two dates and calculate the number of days between them. 
All these things and more are possible using formula fields.

What if you wanted to calculate how many days are left until an opportunity’s 
close date. You can create a simple formula field that automatically calculates 
that value. By adding the value to the Opportunity page layout, your users can 
quickly access this key information. You can also add this field to reports and 
list views for instant access.

When you’re first learning formulas, it’s best to start with simple calculations 
and build up to more complex scenarios.

// To create custom formula fields on any standard or custom object:

1. Search for the object that we want to work with.

2. Click on the name of the object.

3. Look under the "Custom Fields and Relationships" section, and click on the New button

3. Select Formula and click Next.

4. In Field Label, type My Formula Field. Notice that Field Name populates 

5. Select the type of data you expect your formula to return. For example, if 
   you want to write a formula that calculates the commission a salesperson 
   receives on a sale, you select Currency. For now, pick Text.

6. Click Next. You’ve arrived at the formula editor!

// To create a formula to display the account number on the Contact page:

1. From Setup, navigate to Customize | Contacts | Fields.

2. In Contact Custom Fields & Relationships, click New.

3. For the field type, select Formula and click Next.

4. Call your field Account Number and select Text for the formula return type. 

5. Click Next.

6. Click Insert Field on the Advanced Formula Editor. 
    Select Contact | Account | Account Number and then click Insert.

The formula field does not need to be complicated.  It can just simply reference 
another field.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License