Formula Magic

115
Formula Magic Administrators Bruce Coe: salesforce.com Lori Sarsfield: salesforce.com Martha Seneta: EnerNOC Frank Loiseaux-Purcell: salesforce.com

description

Ever wonder how you can really exploit the power of formulas? Want to learn some new, advanced automation tricks? Well, this is the session for you! There are so many ways to use formula fields, roll-up summary fields, and workflow and validation rules effectively to drive data integrity, make calculations, and provide powerful insight for your users. Join us for this advanced session on how to build useful formulas designed to enhance your data and streamline your processes.

Transcript of Formula Magic

Page 1: Formula Magic

Formula MagicAdministrators

Bruce Coe: salesforce.comLori Sarsfield: salesforce.comMartha Seneta: EnerNOCFrank Loiseaux-Purcell: salesforce.com

Page 2: Formula Magic

Safe HarborSafe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year ended January 31, 2010. This documents and others are available on the SEC Filings section of the Investor Information section of our Web site.

Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Page 3: Formula Magic

Formula Magic: Agenda

I. Introduction / Goals

II. Case Studies: Lori Sarsfield

III. Formula Essentials

IV. Guest Speaker: Martha Seneta, EnerNOC

V. Formula Methodology

VI. Case Studies: Frank Loiseaux-Purcell

VII. Wrap-up Q&A

Page 4: Formula Magic

Formula Magic: Goals

Demonstrate the power and flexibility of formulas

Examine advanced formula solutions in case studies

Discuss formula essentials and methodology

Distinguish formula solutions vs. Apex coding

Page 5: Formula Magic

Formula Magic: Key Takeaways

Learn new ways to automate your processes

Add to your formula knowledge arsenal

Simplify formula creation and maintenance

Learn ways to teach formulas to your co-admins

Make the system work for you!

Page 6: Formula Magic

Automation = Better Data + Less Work

Reduce / eliminate: Manual, redundant data entry

Loss of data integrity

Data errors

Increase / maximize: Usage efficiency

Data integrity

Availability of reliable data

Page 7: Formula Magic

Formula Magic: Bottom Line

Make the system work for you!

Page 8: Formula Magic
Page 9: Formula Magic

Lori Sarsfield

salesforce.com

Professional Services

Page 10: Formula Magic

Improve the User Productivity!

Samples of real world formulas:

To provide better reporting, filtering capabilities to users

To improve identification of new business opportunities

To enforce data entry standards

Page 11: Formula Magic

Owner Field Formulas

Have you ever needed access to additional record

owner attributes to:– Use with mail merge functionality?

– Display owner attributes on a detail record?

– Facilitate reporting, list views, and campaign segmentation?

Page 12: Formula Magic

Owner Field Formulas

Hey – why don’t I just formula fields to pull in owner attributes?!?!?– No “>” next to the owner field that provides access to related owner

attributes

“>” is present for non-owner id lookups

Page 13: Formula Magic

Owner Attributes Solution Example

Use apex and formula fields to easily solve– Step 1: Create a custom lookup field to the user object

– Step 2: Create a simple trigger upon insert of record or update

of Owner field to populate a custom user lookup field

– Step 3: Create formula fields for any field on user object based

on custom user lookup field

Page 14: Formula Magic

Owner Attributes Solution Example

Custom user lookup field allows cross object access

to all user fields!

Page 15: Formula Magic

Owner Attributes Solution Example

Pull in owner contact info to include in mail merges!

Use formulas to split out owner Role name into attributes that can use used in reports, list views, or campaign filtering criteria!

Page 16: Formula Magic

Facilitating Cross Sell/UpSell

Current view of products owned by a customer using a related list

Page 17: Formula Magic

Alternate Solution

Use roll up summary and image formula fields to display current

product ownership and opportunities for cross sell and upsell

Page 18: Formula Magic

Solution Details

Create roll up summary fields that COUNTS the number of product

records of certain types to the customer record

Page 19: Formula Magic

Solution Details

Create IMAGE formula fields to display a visual indicator for

product ownership and add these to the page– IMAGE( IF( Checking_Savings_RU__c >0, "/servlet/servlet.FileDownload?

file=01580000001KPi5",

"/servlet/servlet.FileDownload?file=01580000001KPiA"), "Product")

Id’s in formula reference check mark and “x” images saved in the

documents tab

Page 20: Formula Magic

REGEX Formula Function

What the heck is a “regular expression”?– A template for the format of text strings

– Think: Social Security Numbers, Zip Codes, Dates

Commonly used in salesforce validation rules to enforce the format

of text strings

*REGEX only available in SOME formula contexts (not formula fields)

Page 21: Formula Magic

Sample REGEX Application

Have you ever had a request to have date picker fields go back

more than one year?

Page 22: Formula Magic

Alternative Date Field Solution

Step 1: Create a custom text field for date entry & enforce use

help text for format assistance to user

Page 23: Formula Magic

Alternative Date Field Solution

Step 2: Create a validation rule with the REGEX function that

validates the format entered is valid:

You don’t need to be a developer to use these!– Samples found in online help & training

– Example above was copied from an internet site

Page 24: Formula Magic

Alternative Date Field Solution

This date entry is accepted:

But this one is not:

Page 25: Formula Magic

Take it one step further!

Create a workflow rule or use apex to copy this date

into a standard date field hidden “behind the scenes”

Converting to standard date field allows users to filter

information on the date easier in list views, reports, etc

Page 26: Formula Magic
Page 27: Formula Magic

Bruce Coe

salesforce.com

Premier Support

Page 28: Formula Magic

Bruce Coe – Other Activities

AYSO soccer referee

Little League umpire

Guitar in Beatles tribute bands

Page 29: Formula Magic

Formula Essentials

Page 30: Formula Magic

Essentials: Formula Fields

Small scripts

Display real-time result

Do NOT store any data

Page 31: Formula Magic

Essentials: Formula Fields

Always Read-ONLY

Can call other formula fields

Page 32: Formula Magic

Formula Fields calling other Formula Fields

Inherits the code of the referenced field, NOT the result.

That’s why… order doesn’t matter.

PROBLEM: Formula >5000 characters

SOLUTION: Wait & see!!...

Page 33: Formula Magic

Essentials: Formula Fields

Formula fields:

• NEVER store data

• NEVER in data exports

• NEVER in Global Search

• NEVER in Lead mapping

• NEVER show up in [New] or [Edit]

Page 34: Formula Magic

Formulas are NOT just in Formula Fields!!

Formulas are ALSO found in…

Validation Rules

Workflow Rules

Assignment Rules

Auto-Resonse Rules

Escalation Rules

Page 35: Formula Magic

Essentials: Validation Rules

Trigger on [Save]

Display RED error message

Prevent [Save] with invalid data

Page 36: Formula Magic

The “IF” is implied

Formula: True/False

THEN Show error

Essentials: Validation Rules

Page 37: Formula Magic

Essentials: Validation Rules

Automatic reminder to user

Enforces manual data correction

Page 38: Formula Magic

Essentials: Workflow Rules

Triggered on [Save]

Implied “IF”

Condition (True/False)

Implied “THEN” = Actions: Email

Task

Field Update

Outbound Message (API call)

Page 39: Formula Magic

Essentials: Workflow Rules

Pointers:

WF rules cannot call other WF rules

Cannot control order; so combine

Use TRUE in formula for ALWAYS

Page 40: Formula Magic

Essentials: Workflow Rules

HOT TIP: WF Field Updates can have complex logic

CASE( YEAR( due_date__c ),

2007, "INXS",

2008, "Foo- Fighters",

2009, "Black Crows",

2010, "Stevie Wonder",

"TBD” )

Page 41: Formula Magic

“…did not previously meet the rule criteria”

NOT record lifetime

[Edit] [Save]

Page 42: Formula Magic

Order of Execution

Browse to:

http://developer.force.com

Search: “order [execution]”

Page 43: Formula Magic

Formula Visibility to Other Data

Formulas CAN see:

Fields on the current record

Fields on parent or grandparent records (cross-object)

System information such as $Profile, $User

Formulas CANNOT see:

Other records in same object

Child records (use Rollup Summary Fields instead)

Unrelated objects

Page 44: Formula Magic

End ofFormula Essentials

Page 45: Formula Magic
Page 46: Formula Magic

Customer Speaker Martha Seneta

EnerNOC, Inc.

Page 47: Formula Magic

EnerNOC: Energy management services and applications

Page 48: Formula Magic

Who is EnerNOC?

• Founded in 2003 • HQ in Boston, MA

• ~200M USD revenue • Offices in Canada, UK, across US; continued international expansion

• NASDAQ ticker: ENOC • ~500 employees ( almost all SFDC users)

Page 49: Formula Magic

What does EnerNOC do?

DemandSMART Earn money by reducing energy use during emergencies and other critical periods.

EfficiencySMART Actively manage your energy consumption via advanced monitoring, new insights, and expert advice.

SupplySMART Let us demystify the complex workings of the energy markets—and help your business get the best rates and energy solution.

CarbonSMART Measure, manage, and report greenhouse gas emissions, and take actionable steps to reduce your facility's carbon emissions and energy costs.

Page 50: Formula Magic

What’s my role at EnerNOC?

Title: Application Systems Analyst

Systems I support: Salesforce.com, Service-

now.com, and Crystal Reports

Responsibilities: Development and support;

enhancement prioritization and approval; release

management; training and documentation

Page 51: Formula Magic

My other EnerNOC role . . .

Page 52: Formula Magic

How to track customer/prospect verticals?

Page 53: Formula Magic

What’s the problem?

Business need: How to tailor to certain verticals?• Success in selling

• Success in execution

Business issues– Why not just have people select the “Industry” value?

• Inaccuracies & inconsistencies

• Takes time

• Categorizations are too broad

– Why not just use the data vendor’s “Industry” value?• Categorizations are too narrow

Page 54: Formula Magic

So, what source should we use for verticals?

NAICS Code

– 6 digits, each with an increased level of granularity• As an example, consider NAICS Code 311330:

31 Manufacturing (Sector)

311 Food Manufacturing (Sub-sector)

3113 Sugar and Confectionery Product Manufacturing (Industry group)

31133 Confectionery Manufacturing from Purchased Chocolate (Industry)

Page 55: Formula Magic

How do we get the right level of detail?

The “3rd digit” of significance (sub-sector) seemed right

for us– Narrow enough to be meaningful

– Broad enough to facilitate reporting

This is where formulas come in!

Page 56: Formula Magic

Use a formula to map the code to a meaning

Looking good, right?

Page 57: Formula Magic

The formula’s too big!

Doh! . . . we hit compiled-size limits!

Page 58: Formula Magic

Breaking the formula into pieces

What if we split the formula across multiple fields?– It will pass compile-size tests if we break it into 3 fields

• “NAICS 3-Digit Industry 1-399”

• “NAICS 3-Digit Industry 400-549”

• “NAICS 3-Digit Industry 550-999”

– Only 1 of the 3 fields will return a meaningful value

Page 59: Formula Magic

How will this work?

We don’t want 3 more fields on page layout

Don’t want to have to include 3 fields in reports

Page 60: Formula Magic

Can we use a formula to combine the 3 fields?

Will this work?

Page 61: Formula Magic

Compiled-size limit strikes again!

Referenced formulas are included in compiled size

Page 62: Formula Magic

Workflow to the rescue!

Create final text field (not formula)

Workflow rule identifies changes to NAICS Code

Field update consolidates formula results into text field

Page 63: Formula Magic

Finally . . . we got what we wanted!

Industry is now displayed at the desired level of

granularity for all records with a NAICS Code value!

Page 64: Formula Magic

How to format “Phone” field in a way that will please everyone?

Page 65: Formula Magic

What’s the problem?

Business need: How to format phone field?– Used for one-click dials, automated dials, and de-duping

Business issue: Many different parties to satisfy

User group Requirement

Event notification system “Phone” and “Extension” in separate fields

US Sales – North America “Phone” and “Extension” in single field

US Sales – International International country codes included

International Sales International country codes excluded

Lead Gen No extensions, no formatting

Page 66: Formula Magic

Why not create separate Phone entry fields?

How would this work?– UK and US could enter their numbers in separate fields

• Including extensions

• Including or excluding country codes as needed

– Ops could enter numbers in a different field without extensions

– Lead Gen could enter numbers in another field with no

formatting

Sounds like we’d be defeating the purpose of CRM!– Need to maintain a single point for management of phone

number data

Page 67: Formula Magic

This is where formulas come in!

One field for data management, many fields for data

consumption– Let’s keep the out-of-the-box “Phone” field as our entry point

for phone number content, and display that content in different

ways using formula fields!

Page 68: Formula Magic

We can satisfy the event notification vendor . . .

Create a separate entry field to capture extension

Use validation to ensure that no extension is entered

into regular “Phone” field

Page 69: Formula Magic

We can satisfy US-based Sales team . . .

Create a formula field to display the “Phone” field and

the new “Phone Extension” field together

This enables one-click dialing from PDA

Page 70: Formula Magic

We can make it easy for US to dial int’l . . .

Use validation to ensure that international numbers are

always entered with country codes included

Page 71: Formula Magic

We can make it easy for int’l to dial locally . . .

Create a formula field that removes the country codes

This enables one-click dialing from PDA for local Sales

teams

Page 72: Formula Magic

. . . And we can make it easy to de-dup

Create a formula field

that removes commonly

used punctuation

marks, and displays

only the local portion of

a number (i.e., the

right-most 8 digits)

Page 73: Formula Magic

Mission accomplished!

One place to manage data, many different views

Each field can be exposed only where needed

“Phone” (OOB field) 011441603692000

“Phone Extension” 2044

“Phone and Extension” 011441603692000 x2044

“International Phone” 01603692000

“Phone Stripped” 03692000

Page 74: Formula Magic

A few points to consider

Page 75: Formula Magic

Leverage all your configuration options

By splitting a formula into smaller pieces and

utilizing workflow, we achieved a single field from

which to consume “translated” NAICS Codes –

without hitting compiled-size limits.

By using one formula (“Phone and Extension”)

within another (“International Phone”), we avoided

having to duplicate code to display data from both the

“Phone” and “Phone Extension” fields.

Page 76: Formula Magic

Keep data entry in as few fields as possible

For reporting and data entry purposes, try to keep a

single point of entry to capture the content of a field.

Use formulas to map that data content into different

views.

Expose each formula view in different places as

needed.

Page 77: Formula Magic

Configuration vs. coding

Examples we looked at could have been handled via

coding rather than configuration.

Coding can be easier to manage because logic is held

in one place . . .

. . . BUT, coding takes a lot longer to build and deploy --

Even more importantly, we want these rules to be

supportable by admins, not just by developers!

Page 78: Formula Magic
Page 79: Formula Magic

Formula Methodology

Page 80: Formula Magic

Formula Design Methodology – PURPOSE!!

Achieve Business Need

Complete your automation quickly

Minimize complexity

Streamline maintenance

Make components easy to understand

Page 81: Formula Magic

Formula Design Methodology – PROCESS!!

1. Discuss Business Need & possible solutions

2. Write requirements and proposed solution

3. Pseudo-code; i.e. plain English

4. Sandbox

5. START SMALL!! Build piece by piece

6. Check syntax along the way

7. [Insert Field] and [Insert Function]

8. Name, Description, and inline comments

Page 82: Formula Magic

Formula Suggestions & Pointers

Page 83: Formula Magic

Functions in Formulas

Take advantage of the help provided whenever you click

on a function name in the Functions list:

Syntax

Description

Return data type

Help & samples

Page 84: Formula Magic

Logical Operators

AND() function = && operator

OR() function = || operator

Suggestion: Use && and || for better readability and

easier trouble-shooting than AND() and OR()

Ex: AND( Closed, Won ) vs. Closed && Won

Page 85: Formula Magic

Picklist fields: Which functions?

Picklists work with these functions:

ISPICKVAL

TEXT

CASE

Key points: TEXT() allows any text function to work on picklist value

TEXT() allows cross-object picklist view dynamically

Page 86: Formula Magic

Picklist fields: Number values

“It looks like a number…”

PROBLEM: “Number” entries are NOT actual numbers

Actually just another picklist value

SOLUTION: Use VALUE( TEXT( Fld )) to get true number

Page 87: Formula Magic

Formula Field NULL Treatment Option

Key point:

For “NULL” or “BLANK” functions on formula fields,

select “Treat blank fields as zeroes”.

Page 88: Formula Magic

Date & Time Format and Functions

DateTime format: YYYY-MM-DDTHH:mm:SS.sssZ

Ex: Hour of Day = MID( CreateDate , 12 , 2 )

Key point:

Formulas see date/time in GMT only

Ex. Adjust for Eastern Time: ( CreateDate – (1/24 * 5) )

Use custom field $User.GMT_Adjustment_in_Hours__c

Page 89: Formula Magic

End ofFormula Methodology

Page 90: Formula Magic
Page 91: Formula Magic

Frank Loiseaux-Purcell

salesforce.com

Solutions Manager

Page 92: Formula Magic

Making complex simplea Tale of two use-cases

Page 93: Formula Magic

How to make complex processes simple

Problem– You have a complex approval process and as Account

Executive you would like visibility into who needs to approve

your contract

– During the approval process you would also like to know where

you are in the approval process

Page 94: Formula Magic

How to make complex processes simple

Solution is formula fields!

Red Flag = Not yet ApprovedOrange Flag = Waiting ApprovalGreen Flag = ApprovedNot Required = Not Required

Page 95: Formula Magic

How to make complex processes simple

How was it built?– Enhancement to Product object to include a flag “Inc in Order

Management”. Which ensures the contract goes through Order

Management approval.

– Workflow field updates to bring over the flag when added to an

opportunity

– Approval Processes defined (multiple to maximize through put

by doing as many of the approvals in parallel. Along with Field

updates which the formulas pickup on and display status

Page 96: Formula Magic

How was it built? Contract custom fields

How was it built?

Page 97: Formula Magic

How was it built? IMAGE function

Page 98: Formula Magic

How to use formula’s to modify forecasting?

Problem:– Your company does not want to forecast all products on an

opportunity.

– For example you sell software and professional services and

only want to forecast software sales not the professional

services.

Page 99: Formula Magic

How to use formula’s to modify forecasting

Solution formula fields on Product

Booking Value is the total of the software sales and the Renamed Amount Field. This is what flows into Forecasting

Page 100: Formula Magic

How to use formula’s to modify forecasting

Opportunity Information

Booking Value – Sum of all Total Price (This is the renamed Amount field)

Total Opportunity Value – Sum of all Total Sales Price (Calculated field to include all products) 

Opportunity Product Information

 

Old Sales Price – Contains unit price of product only for those products included in the forecast (not

shown on the Opportunity Screen). This is the original SFDC Sales Price.

 

Total Price - Contains value for the products included in the forecast (Qty * Old Sales Price)

 

Custom Opportunity Product Information

 

Sales Price Unit price of product for all products

Total Sales Price Total sales price for product (Qty * Sales Price)

Total Contract Value Separate entry for network, managed services, and professional services to

contain the total contract value for the product.

Page 101: Formula Magic
Page 102: Formula Magic

Mini-Case Studies

Page 103: Formula Magic

HELP! Product Name for Opportunity

PROBLEM: I can’t I see Product Name in my Opportunity

Rollup Summary Fields?

REASON: Opportunity and Product are BOTH parent

objects to Opportunity Product; i.e. can’t see each other

SOLUTION: Make a WF rule on Opportunity Product

to copy Product Name to new Opportunity Product field

Page 104: Formula Magic

HELP! Set record types from Convert Lead

PROBLEM: How to set record type of new Account,

Contact, and Opportunity during Lead Conversion?

SOLUTION:- Hidden text fields on Acct/Contact/Oppty: "Lead Record Type“

- Hidden formula fields on Lead: "Lead Record Type - Account“ [Contact, Opportunity]

- Map the Lead formula field to each of those text fields

- WF rule on Acct/Contact/Oppty: When created, criteria: "Lead Record Type" (local

hidden field) <equals> “<GivenRecordType>"

- WF field update: set the Record Type field (Acct/Contact/Oppty) to whichever record

type should be set from Lead Record Type “<GivenRecordType>"

Page 105: Formula Magic

HELP! How to make Round Robin?

PROBLEM: Need to evenly and automatically distribute

Cases or Leads to owners using round robin approach

SOLUTION:

Create a Round Robin and use in Assignment Rules:

1. Create an Auto-number field

2. Create a formula field:

MOD( AutoNumber__c , <Number for Round Robin> )

Page 106: Formula Magic

HELP! Decimal Precision with Formulas

PROBLEM: Two formula fields each with 2 decimal places

appear to be equal but show as NOT equal.

REASON: The comparison ignores the 2-decimal display

and instead uses more decimal places.

SOLUTION: Use the following in the calling formula:

ROUND( FormulaField_N__c , 2 )

Page 107: Formula Magic

HELP! Automatic Customer Status Field

PROBLEM: How to show dynamically whether each

Account is a Customer yet or not?

SOLUTION:

1. Create a hidden Rollup Summary Field on Account to show

COUNT of child Closed/Won Opportunities

2. Create and show a formula field (Text) on Account to be called "Is

Customer" to show "Yes“/"Not yet" based on whether RSF >0

Page 108: Formula Magic
Page 109: Formula Magic

Formula Magic Wrap-up

Page 110: Formula Magic

Automation = Better Data + Less Work

Reduce / eliminate: Manual, redundant data entry

Loss of data integrity

Data errors

Increase / maximize: Usage efficiency

Data integrity

Availability of reliable data

Page 111: Formula Magic

Formula Magic: Key Takeaways

Learn new ways to automate your processes

Add to your formula knowledge arsenal

Simplify formula creation and maintenance

Learn ways to teach formulas to your co-admins

Make the system work for you!

Page 112: Formula Magic

So why call it “Formula MAGIC”?

Technical system administrators:

We know that formulas are not magic

They are a logical, linear set of conditions and actions

Formulas are not magic to me or you…

…but they are to your system users

and to your business.

Page 113: Formula Magic

Formula Magic

Page 114: Formula Magic

D I S C O V E R

Visit Customer Success Team at Campground

Discover

Training

Learning Paths

Experience

Product

Demos

Learn about Customer

Resources

the products, services and resources

Meet Success Experts

S U C C E S S

Find us at the Customer Success Team area of Salesforce.com Campground at Moscone North

Learn about how to win prizes including 10 iPads & more!

that help you achieve

Page 115: Formula Magic

How Could Dreamforce Be Better? Tell Us!

Log in to the Dreamforce app to submit

surveys for the sessions you attendedUse the

Dreamforce Mobile app to submit

surveysEvery session survey you submit is

a chance to win an iPod nano!

OR