Field Validation Formulas
Field Validation Formulas
Account Rating
This formula evaluates Annual Revenue, Billing Country, and Type, and assigns a value of Hot,
Warm, or Cold.
Account.Account_Rating__c
Account Region
This formula returns a text value of North, South, East, West, or Central based on the Billing
State/Province of the account.
IF(ISBLANK(BillingState), "None",
IF(CONTAINS("AK:AZ:CA:HA:NV:NM:OR:UT:WA", BillingState), "West",
IF(CONTAINS("CO:ID:MT:KS:OK:TX:WY", BillingState), "Central",
IF(CONTAINS("CT:ME:MA:NH:NY:PA:RI:VT", BillingState), "East",
IF(CONTAINS("AL:AR:DC:DE:FL:GA:KY:LA:MD:MS:NC:NJ:SC:TN:VA:WV",
BillingState), "South",
IF(CONTAINS("IL:IN:IA:MI:MN:MO:NE:ND:OH:SD:WI", BillingState), "North",
"Other"))))))
For details about using these functions, see IF, LEN, and CONTAINS.
Contract Aging
This formula calculates the number of days since a contract with an account was activated. If the contract Status is
not Activated, this field is blank.
IF(ISPICKVAL(Contract_Status__c, "Activated"),
NOW() - Contract_Activated_Date__c, null)
For details about using these functions, see IF, ISPICKVAL, and NOW.
TODAY()-Date_in_approval__c
For details about using this function, see TODAY.
CASE(MONTH(LastActivityDate),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December",
"None")
For details about using these functions, see CASE and MONTH.
This formula returns the month that your service-level agreement expires. This example uses a custom date field
called SLA Expiration Date.
MONTH(SLAExpirationDate__c)
For details about using this function, see MONTH.
HYPERLINK(
"http://newssearch.bbc.co.uk/cgibin/search/results.pl?scope=newsifs;tab=news;q="&Name,
"BBC News")
Bloomberg News Search
This formula creates a link to an account's ticker symbol on the Bloomberg website.
HYPERLINK(
"http://www.bloomberg.com/apps/quote?ticker="&TickerSymbol,
"Bloomberg News")
CNN News Search
This formula creates a link to a CNN news search site using the Account Name.
HYPERLINK(
"http://websearch.cnn.com/search/search?source=cnn&
invocationType=search%2Ftop&sites=web&query="&Name,
"CNN News")
MarketWatch Search
This formula creates a link to an account's ticker symbol on the Marketwatch.com website.
HYPERLINK(
"http://www.marketwatch.com/tools/quotes/quotes.asp?symb="&TickerSymbol,
"Marketwatch")
Google Search
This formula creates a link to a Google search site using the Account Name.
HYPERLINK(
"http://www.google.com/search?en&q="&Name,
"Google")
Google News Search
This formula creates a link to a Google news search site using the Account Name.
HYPERLINK(
"http://www.google.com/news?en&q="&Name,
"Google News")
Yahoo! Search
This formula creates a link to a Yahoo! search site using the Account Name.
HYPERLINK(
"http://search.yahoo.com/search?p="&Name,
"Yahoo Search")
Yahoo! News Search
This formula creates a link to a Yahoo! news search site using the Account Name.
HYPERLINK(
"http://news.search.yahoo.com/search/news?p="&Name,
"Yahoo News")
For details about using the function used in these formulas, see HYPERLINK.
Case Management
Autodial
This formula creates a linkable phone number field that automatically dials the phone number when clicked. In this
example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial.
The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells
the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable
text the user clicks to dial.
CASE(Days_Open__c, 3,
"Reassign", 2, "Assign Task", "Maintain")
The following text is displayed:
IF(IsClosed,
null,
NOW() - CreatedDate )
For details about using these functions, see IF and NOW.
IF(IsClosed,
ROUND(ClosedDate - CreatedDate, 0), ROUND((NOW() - CreatedDate),0))
For details about using these functions, see IF, ROUND, and NOW.
Case Categorization
This formula displays a text value of RED, YELLOW, or GREEN, depending on the value of a case age custom
text field.
CASE (Priority,
"High", CreatedDate + 2,
"Medium",CreatedDate + 5,
CreatedDate + 7)
For details about using this function, see CASE.
CASE(Product_Purch__c,
"Printer", "Extra toner cartridges", "Camera", "Memory cards",
"Special of the day")
For details about using this function, see CASE.
Suggested Offers
This formula suggests a product based on the support history for a computer reseller. When the Problem custom
field matches a field, the formula field returns a suggestion.
CASE(Problem__c,
"Memory", "Suggest new memory cards", "Hard Drive failure", "Suggest new
hard drive with tape backup",
"")
For details about using this function, see CASE.
Commission Calculations
Commission Amounts for Opportunities
The following is a simple formula where commission is based on a flat 2% of the opportunity Amount.
Commission Maximum
This formula determines what commission to log for an asset based on which is greater: the user's commission
percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example
assumes you have two custom percent fields on users and assets.
MAX($User.Commission_Percent__c * Price,
Price * Account_Discount__c, 100)
For details about using this function, see MAX.
Contact Management
Contact's Account Creation Date
This date formula displays the account's Created Date field on the contacts page.
Account.CreatedDate
Contact's Account Discount Percent
This percent formula displays the account's Discount Percent field on the contacts page.
Account.Discount_Percent__c
Contact's Account Name
This formula displays the standard Account Name field on the contacts page.
Account.Name
Contact's Account Phone
This formula displays the standard Account Phone field on the contacts page.
Account.Phone
Contact's Account Rating
Use this formula to display the Account Rating field on the contacts page.
Account.Website
If the account website URL is long, use the HYPERLINK function to display a label such as Click Here instead of the
URL. For example:
IF(Account.Website="", "",
IF(
OR(LEFT(Account.Website, 7) = "http://",LEFT(Account.Website,
8) = "https://"),
HYPERLINK( Account.Website , "Click Here" ),
HYPERLINK( "http://" & Account.Website , "Click Here" )
)
)
This formula also adds the necessary "http://" or "https://" before a URL if neither were included in the URL field.
For details about using this function, see HYPERLINK.
Contacts Age
Use this formula to calculate a persons age based on a standard field called Birthdate. The persons
Birthdate is subtracted from todays date, which returns the number of days since the persons Birthdate.
This number is divided by the number of days in a year and rounded down to the nearest integer.
FLOOR((TODAY()-Birthdate)/365.2425)
For details about using these functions, see FLOOR and TODAY.
Contact's Birthday
This formula displays the value Yes if the contacts birthday falls in the current calendar month.
IF (
MONTH( Birthdate) = MONTH( TODAY()), "Yes", "")
For details about using these functions, see IF, MONTH, and TODAY.
2.
3.
4.
http://www.linkedin.com/search/fpsearch?type=people&keywords={!Contac
t.FirstName}+{!Contact.LastName}
5.
Click Save.
Remember to add this link to the Contact page layout in order for it to show up.
This formula displays the contacts preferred contact method in a contact related listwork phone, home phone, or
mobile phonebased on a selected option in a Preferred Phone custom picklist.
CASE(Preferred_Phone__c,
"Work", "w. " & Phone,
"Home", "h. " & HomePhone,
"Mobile", "m. " & MobilePhone,
"No Preferred Phone")
For details about using this function, see CASE.
Contact Priority
This formula assesses the importance of a contact based on the account rating and the contact's title. If the account
rating is Hot or the title starts with Executive, then the priority is high (P1). If the account rating is Warm or the
title starts with VP then the priority is medium (P2), and if the account rating is Cold then the priority is low (P3).
"P3")
)
)
Contact Yahoo! ID
This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users
can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field
called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID.
For details about using these functions, see HYPERLINK and IMAGE.
CASE(ShippingCountry,
"USA",
ShippingStreet & BR() &
ShippingCity & ",
" & ShippingState & " " &
ShippingPostalCode & BR()
& ShippingCountry,
"France",
ShippingStreet & BR() &
ShippingPostalCode & " " &
ShippingCity & BR() &
ShippingCountry, "etc")
For details about using this function, see CASE and BR.
CASE(MailingCountry,
"USA", "1",
"Canada", "1",
"France", "33",
"UK", "44",
"Australia", "61",
"Japan", "81",
"?")
For details about using this function, see CASE.
Data Categorization
Deal Size Large and Small
This formula displays Large Deal for deals over one million dollars or Small Deal for deals under one million
dollars.
IF(AND(Price<1,Quantity<1),"Small", null)
For details about using these functions, see IF and AND.
Product Categorization
This formula checks the content of a custom text field named Product_Type and returns Parts for any product
with the word part in it. Otherwise, it returns Service. Note that the values are case sensitive, so if a
Product_Type field contains the text Part or PART, this formula returns Services.
Date Calculations
Birthday in Current Year Accounting for Leap Years
This formula returns the date of a person's birthday in the current year, even if the person's birthday is on February
29th in a leap year.
CASE(
MOD(TODAY() - DATE(1900, 1, 7), 7),
0, "Sunday",
1, "Monday",
2, "Tuesday",
3, "Wednesday",
4, "Thursday",
5, "Friday",
6, "Saturday", "Error")
For details about using these functions, see CASE, MOD, TODAY, and DATE.
Day of Year
This formula calculates todays numeric day of the year (a number between 1 and 365).
TODAY() DATE(YEAR(TODAY()), 1, 1) + 1
For details about using these functions, see TODAY, DATE, and YEAR.
IF(
MONTH(CloseDate)=12,
DATE(YEAR(CloseDate),12,31) - CloseDate,
DATE(YEAR(CloseDate),
MONTH(CloseDate)+1,1) - CloseDate-1)
For details about using these functions, see IF, MONTH, DATE, and YEAR.
Time of Day
This formula returns the time of day in Greenwich Mean Time (GMT), for example: 20:04 PM).
Discounting
Maintenance and Services Discount
This formula field uses two custom currency fields: Maintenance Amount and Services Amount. It displays
Discounted on an opportunity if its maintenance amount and services amount do not equal the opportunity Amount
standard field value. Otherwise, it displays "Full Price."
Amount - Discount_Amount__c
For details about using this operator, see - (Subtract).
ROUND(Amount-Amount* Discount_Percent__c,2)
For details about using this function, see ROUND.
Employee Services
Bonus Calculation
This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross
times bonus percent or an equally divided amount of the company's performance amount among all employees. It
assumes you have custom number field for Number of Employees, a custom percent field for Bonus
Percent, and currency custom fields for the employee's Gross and company's Performance.
MIN(Gross__c * Bonus_Percent__c,
Performance__c / Number_of_Employees__c)
For details about using this function, see MIN.
Employee 401K
This example formula determines which amount to provide in employee 401K matching based on a matching
program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field
for Contribution.
Total Pay =
IF(Total_Hours__c <= 40, Total_Hours__c * Hourly_Rate__c,
40 * Hourly_Rate__c +
(Total_Hours__c - 40) * Overtime_Rate__c)
For details about using this function, see IF.
Expense Tracking
Expense Identifier
This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field
that uses an expense number custom field.
Mileage Calculation
This formula calculates mileage expenses for visiting a customer site at 35 cents a mile.
Miles_Driven__c * 0.35
For details about using this operator, see * (Multiply).
Financial Calculations
Compound Interest
This formula calculates the interest, you will have after T years, compounded M times per year.
Principal__c * ( 1 + Rate__c / M ) ^ ( T * M) )
For details about using these operators, see * (Multiply), / (Divide), and ^ (Exponentiation).
Principal__c * EXP(Rate__c * T)
Consultant Cost
This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type
and consulting charges a rate of $1200 per day. Note that Consulting Days is a custom field on opportunities.
Consulting_Days__c * 1200
For details about using this operator, see * (Multiply).
Gross Margin
This formula provides a simple calculation of gross margin. In this formula example, Total Sales and Cost of
Goods Sold are custom currency fields.
Total_Sales__c - Cost_of_Goods_Sold__c
For details about using this operator, see - (Subtract).
Payment Status
This formula determines if the payment due date is past and the payment status is UNPAID. If so, it returns the text
PAYMENT OVERDUE and if not, it leaves the field blank. This example uses a custom date field called Payment
Due Date and a text custom field called Payment Status on contracts.
IF(
AND(Payment_Due_Date__c < TODAY(),
ISPICKVAL(Payment_Status__c, "UNPAID")),
"PAYMENT OVERDUE",
null )
For details about using these functions, see IF, AND, TODAY, and ISPICKVAL.
Image Links
Yahoo! Instant Messenger Image
This formula displays an image that indicates whether a contact or user is currently logged in to Yahoo! Instant
Messenger. Clicking the image launches the Yahoo! Instant Messenger window. This formula uses a custom text field
called Yahoo Name to store the contact or users Yahoo! ID.
IMAGE(
CASE( Priority,
"Low", "/img/samples/flag_green.gif",
"Medium", "/img/samples/flag_yellow.gif",
"High", "/img/samples/flag_red.gif",
"/s.gif"),
"Priority Flag")
For details about using this function, see IMAGE.
This formula displays a 30 x 30 pixel image of a red, yellow, or green, depending on the value of a Case Age
custom text field.
IMAGE(
CASE(Project_Status__c,
"Green", "/img/samples/light_green.gif",
"Yellow", "/img/samples/light_yellow.gif",
"Red", "/img/samples/light_red.gif",
"/s.gif"),
"status color")
For details about using these functions, see IMAGE and CASE.
IMAGE(
CASE(Rating__c,
"1", "/img/samples/stars_100.gif",
"2", "/img/samples/stars_200.gif",
"3", "/img/samples/stars_300.gif",
"4", "/img/samples/stars_400.gif",
"5", "/img/samples/stars_500.gif",
"/img/samples/stars_000.gif"),
"rating")
For details about using these functions, see IMAGE and CASE.
IMAGE(
CASE(Rating__c,
"1", "/img/samples/rating1.gif",
"2", "/img/samples/rating2.gif",
"3", "/img/samples/rating3.gif",
"4", "/img/samples/rating4.gif",
"5", "/img/samples/rating5.gif",
"/s.gif"),
"rating")
For details about using these functions, see IMAGE and CASE.
Integration Links
Application API Link
This formula creates a link to an application outside Salesforce, passing the parameters so that it can connect to
Salesforce via the Web services API and create the necessary event.
CASE(Shipping_Method__c,
"Fedex",
HYPERLINK("http://www.fedex.com/Tracking?ascend_header=1&clienttype
=dotcom&cntry_code=us&language=english&tracknumbers= "&
tracking_id__c,"Track"),
"UPS",
HYPERLINK("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVer
sion
=5.0&sort_by=status&loc=en_US&InquiryNumber1= "& tracking_id__c &
"&track.x=32&track.y=7", "Track") ,
"DHL",
HYPERLINK("http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=" &
tracking_id__c,"Track"), "")
For details about using these functions, see CASE and HYPERLINK.
Lead Management
Lead Aging (for open leads)
This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting
the date and time created from the current date and time. The result is the number of days open rounded to zero
decimal places. If the lead is not open, this field is blank.
Lead Numbering
This formula returns a number value for the text value in the auto-number field Lead Number. This can be useful if
you want to use the Lead Number field in a calculation, such as round-robin or other routing purposes. Note that
auto-number fields are text fields and must be converted to a number for numeric calculations.
VALUE(Lead_Number__c)
For details about using this function, see VALUE.
MOD(VALUE(Lead_Number__c), 3)
This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This
formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting
with 1. The MOD function divides the lead number by the number of lead queues available (three in this example)
and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead
records to different queues. For example:
For details about using these functions, see MOD and VALUE.
Metrics
Temperature Conversion
1.8 * degrees_celsius__c + 32
For details about using these operators, see * (Multiply) and + (Add).
Miles__c/.621371192
For details about using this operator, see / (Divide).
Opportunity Management
Days Left to Close
This formula returns the expected number of days left to the close date of an opportunity.
Expected_close_date__c -TODAY()
For details about using this function, see TODAY.
CASE(
MONTH(CloseDate),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December",
"Invalid month")
For details about using these functions, see CASE and MONTH.
Maintenance Calculation
This formula calculates maintenance fees as 20% of license fees per year. Maintenance Years is a custom field
on opportunities.
Monthly_Amount__c * Subscription_Months__c
For details about using this operator, see * (Multiply).
Monthly Value
This formula divides total yearly value by 12 months.
Total_value__c / 12
For details about using this operator, see / (Divide).
Opportunity Categorization
This formula uses conditional logic to populate an Opportunity category text field, based on the value of the
Amount standard field. Opportunities with amounts less than $1500 are Category 1, those between $1500 and
$10000 are Category 2, and the rest are Category 3. This example uses nested IF statements.
IF(Amount < 1500, "Category 1", IF(Amount > 10000, "Category 3",
"Category 2"))
For details about using this function, see IF.
(IF(ISBLANK(Maint_Amount__c), 0, 1) +
IF(ISBLANK(Services_Amount__c), 0,1) +
IF(ISBLANK(Discount_Percent__c), 0, 1) +
IF(ISBLANK(Amount), 0, 1) +
IF(ISBLANK(Timeline__c), 0, 1)) / 5
For details about using this function, see ISBLANK.
Expected_rev_licenses__c * Probability
For details about using this operator, see * (Multiply).
TEXT(ExpectedRevenue)
For details about using this function, see TEXT.
Amount / total_reps__c
For details about using this operator, see / (Divide).
Unit_price__c * Volume__c * 20
For details about using this operator, see * (Multiply).
Consulting_Days__c * 1200
For details about using this operator, see * (Multiply).
CASE(StageName,
"Prospecting", "Insert 1st Document ID",
"Qualification", "Insert 2nd Document ID",
"Needs Analysis", "Insert 3rd Document ID",
"Value Proposition",
)
)
For details about using this function, see CASE.
Sales Coach
This formula creates a hyperlink that opens a stage-specific document stored in the Documents tab. It uses the
previously defined custom formula field that identifies a document based on opportunity Stage. See Stage-Based
Sales Document Selection.
package_weight__c * cost_lb__c
For details about using this operator, see * (Multiply).
Ship_cost__c / total_amount__c
For details about using this operator, see / (Divide).
IF(Probability = 1,
ROUND(Amount * 0.02, 2),
0)
For details about using these functions, see IF and ROUND.
Non_Recurring_Revenue__c + Contract_Length_Months__c *
Recurring_Revenue__c
For details about using these operators, see + (Add) and * (Multiply).
Pricing
Total Amount
This formula calculates a total amount based on unit pricing and total units.
Unit_price__c * Total_units__c
For details about using this operator, see * (Multiply).
User Pricing
This formula calculates a price per user license.
Total_license_rev__c / Number_user_licenses__c
For details about using this operator, see / (Divide).
Project Management
Calculate Intermediate Milestone from End Date
This formula calculates intermediate milestone dates by subtracting days from the end date (for projects that are
planned based on end date).
Release_Date__c - 7 * Phase_duration_in_weeks__c
For details about using this operator, see * (Multiply).
Scoring Calculations
Lead Scoring
This formula scores leads, providing a higher score for phone calls than website requests.
Survey_Question_1__c * 5 + Survey_Question_2__c *2
For details about using these operators, see* (Multiply) and + (Add).