SF Formulas Developer Cheatsheet Web PDF
SF Formulas Developer Cheatsheet Web PDF
SF Formulas Developer Cheatsheet Web PDF
Cheatsheet
Overview
A formula is an expression that derives its value from other fields, expressions, or values. Formulas are used in a number of contexts, including custom
fields for auto-calculating values, criteria for data validation and workflow, as well as in the expression language in Visualforce.
+ Calculates the sum of two values. Evaluates whether at least one of multiple values
|| or expressions is true. Use this operator as an
- Calculates the difference of two values. alternative to the logical function OR.
* Calculates the product of two values.
Determines whether expressions are true or false. Encodes text and merge field values for use in
IF
Returns a given value if true and another if false. JavaScript within HTML tags by inserting escape
JSINHTMLENCODE characters before unsafe JavaScript characters
and replacing characters that are reserved in
Compares the value of a field to the previous value
HTML with HTML entity equivalents.
ISCHANGED and returns TRUE if the values are different. If the
values are the same, this function returns FALSE. Encodes text and merge field values for use
in URLs by replacing characters that are illegal
Checks whether the formula is running during the in URLs, such as blank spaces, with the code
creation of a new record and returns TRUE if it is. that represent those characters as defined in
ISNEW URLENCODE
If an existing record is being updated, this function RFC 3986, Uniform Resource Identifier (URI):
returns FALSE. Generic Syntax. For example, blank spaces
are replaced with %20, and exclamation
points are replaced with %21.
Determines whether a text value is a number and
ISNUMBER
returns TRUE if it is. Otherwise, it returns FALSE.
NOT Returns FALSE for TRUE and TRUE for FALSE. Text Functions
Determines whether text begins with specific
Determines whether expressions are true or false. BEGINS characters and returns TRUE if it does.
OR Returns TRUE if any expression is true. Returns Returns FALSE if it does not.
FALSE if all expressions are false.
BR Inserts a line break in a string of text.
Converts a 15-character ID to a case-
CASESAFEID
insensitive 18-character ID.
Math Functions Compares two arguments of text and returns
CONTAINS TRUE if the first argument contains the
Calculates the absolute value of a number.
second argument. If not, returns FALSE.
ABS The absolute value of a number is the number
without its positive or negative sign. Returns the position of a string within a string
FIND
of text represented as a number.
CEILING Rounds a number up to the nearest integer.
GETSESSIONID Returns the user’s session ID.
Returns a value for e raised to the power of a
EXP HYPERLINK Creates a link to a URL from the specified text.
number you specify.
Inserts an image with alternate text and
Returns a number rounded down to the IMAGE
FLOOR height/width specifications.
nearest integer.
Determines whether any value selected in a
Returns the natural logarithm of a specified INCLUDES multi-select picklist field equals a text literal
LN number. Natural logarithms are based on the you specify.
constant e value of 2.71828182845904.
Determines whether the value of a picklist
ISPICKVAL
LOG Returns the base 10 logarithm of a number. field is equal to a text literal you specify.
MAX Returns the highest number from a list of numbers. Returns the specified number of characters
LEFT
from the beginning of a text string.
MIN Returns the lowest number from a list of numbers.
Returns the number of characters in a
LEN
Returns a remainder after a number is divided by specified text string.
MOD
a specified divisor. Converts all letters in the specified text string
to lowercase. Any characters that are not
Returns the nearest number to a number you LOWER
letters are unaffected by this function.
ROUND specify, constraining the new number by a Locale rules are applied if a locale is provided.
specified number of digits.
Inserts your specified characters to the left
SQRT Returns the positive square root of a given number. LPAD
side of a text string.
Text Functions cont. Advanced Functions
Returns the specified number of characters
MID from the middle of a text string given the Returns an array of strings in the form of
starting position. GETRECORDIDS record IDs for the selected records in a list,
such as a list view or related list.
Returns the specified number of characters from
RIGHT
the end of a text string.
Inserts your specified characters to the right Returns content from an s-control snippet.
RPAD INCLUDE Use this function to reuse common code in
side of a text string.
many s-controls.
SUBSTITUTE Substitutes new text for old text in a text string.
Converts a percent, number, date, date/
Returns a relative URL in the form of a link
time, or currency type field into text anywhere
LINKTO (href and anchor tags) for a custom s-control
TEXT formulas are used. Also, converts picklist
or Salesforce page.
values to text in validation rules, formula fields,
and field updates.
Removes the spaces and tabs from the Compares a text field to a regular expression
TRIM
beginning and end of a text string. and returns TRUE if there is a match.
Converts all letters in the specified text string REGEX Otherwise, it returns FALSE. A
to uppercase. Any characters that are not regular expression is a string used to describe
UPPER a format of a string according to certain
letters are unaffected by this function. Locale
rules are applied if a locale is provided. syntax rules.