Tuesday, June 27, 2017

Salesforce Basics - Formulas, Roll-up Summary

Formula fields have an immeasurable number of uses. See the article "Useful Advanced Formula Fields" for some great examples.

The key is to understand that a formula field can capture and manipulate data. It can pull data from:

  • Any field on the record the formula is created
  • Any field on a record that is linked via lookup relationship (a maximum of 5 lookups)- for instance you can create a formula on the opp object and reference account’s data

The key limitation of formula fields is that they cannot reference data in related lists. For instance, you cannot reference any information about the contact roles on the opportunity in a formula because contact roles is a related list, not a lookup (I’ve been burned by this!).

While your formula fields calculate values using fields within a single record, roll-up summary fields calculate values from a set of related records, such as those in a related list. You can create roll-up summary fields that automatically display a value on a master record based on the values of records in a detail record. These detail records must be directly related to the master through a master-detail relationship.

The key benefit of a roll-up summary is that it performs math on data in related lists. The key limitation is that roll-up summaries are only available for data in a master-detail relationship.

Types of rollup
COUNT (record count of related list)
SUM (addition of field within related list-number/currency/percent only)
MIN (lowest value within related list-number/currency/percent/date/date-time only)
MAX (highest value within related list-number/currency/percent/date/date-time only)

You can only set filter criteria for records to enter into the summary.

Example: Create a field on account that displays the total of all opportunities won for the account: Create the roll-up summary SUM of opportunity.amount and set the filter criteria to stage=won.

No comments:

Post a Comment

Lightning Inter-Component Communication Patterns

Lightning Inter-Component Communication Patterns If you’re comfortable with how a Lightning Component works and want to build producti...