SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
Vincent Finet
Senior Program Architect @ Salesforce
twitter.com/VinceFINET
linkedin.com/in/vincentfinet
trailhead.com/me/vincefinet
I II III
Where do
we found
formulas in
Salesforce?
How will
you build a
working
formula?
Examples
IV
Resources
around
formulas
Expert
Starter
Curious
Middle
Part I
Where do we found
formulas in Salesforce?
Where do we found formulas in Salesforce?
Location #1: Formula Fields
● Characteristics
○ At the Object level, like any other field
○ 8 different types
○ 1 formula expression
○ Value calculated on the fly (= not stored)
○ Cannot be indexed (unless deterministic + SF case)
○ Treat blank behavior (defined for each field)
● Restrictions:
○ Max number of characters: 3900 characters
○ Max formula size upon save: 4000 bytes
○ Max compiled size: 5000 bytes
○ Can’t reference: long text area, encrypted or description.
○ Cross-Object Formulas (across all fields of the same
object): 15
Where do we found formulas in Salesforce?
Location #2: Validation Rules
● Characteristics
○ At the Object level
○ Data quality concerns
○ Can be activated or inactivated
○ Raise an error if a condition is met
○ Save is blocked if any error
○ Error message is raised on the top or on a field
● Restrictions:
○ Little mental gym when writing the formula
because you specify the error condition and not
the success condition
○ Launched only once (for example: not after a
workflow field update)
Where do we found formulas in Salesforce?
Location #3: Workflows
● Characteristics
○ At the Object level
○ Automation concerns
○ Workflow rule: entering formula criteria
○ Workflow field update: new value formula
● Restrictions:
○ Old school automation but still robust!
Where do we found formulas in Salesforce?
Location #4: Process builders
● Characteristics
○ At the Object level
○ Automation concerns
○ Criteria with a boolean formula
● Restrictions:
○ Duplicate formula (leading to errors) if
you have CASE like criterias
Where do we found formulas in Salesforce?
Location #5: Reports
● For a long time, formula in reports were VERY limited, so we had to create
formula field to have formulas in reports
● Use case #1: Cross-Object formula
○ Limit of 15 per object on Formula Fields, WF Rules, WF Field Updates, Approval Processes,
Validation Rules, Assignment Rules, Escalation Rules, and Auto-Response Rules
● Use case #2: Nice icons on report for scoring
○ Use of IMAGE() with standard icons
● Use case #3: “Power Of One”
Part II
How will you build a
working formula?
How will you build a working formula?
The basics
● Literal value
= 'test' = "test"
= 0.4
= TRUE = true = TrUe
● Operator
= FieldA__c & 'ooo'
= (FieldA__c + 8)^2 / 100
● Functions
= AND(aa = 0, bb, ...)
= TODAY()
= ROUND(FieldA__c*0.02, 2)
= HYPERLINK('/'+$User.Id)
= IMAGE('/img/samples/flag_red.gif', 'red')
● Field reference
= FieldA__c
= FieldA__r.Name
= Parent.Parent.Parent.Name
= $CustomMetadata.MyCMDT
= $Label.MyCustomLabel
= $Organization.Id
= $Profile.Name
= $UserRole.DeveloperName
= $User.Id
● Comment
= /* Comment here */
= ROUND( /*:)*/ FieldA__c, /*;|*/ 3)
How will you build a working formula?
Best practices
● Multiple lines
● Indent
● Functions and keywords in UPPERCASE
● Add comments in the formula (if needed)
● Don’t hard code values, use custom labels instead
● Think reusable → multiple formulas instead of one
● Think maintenance → make the formula readable
● Think efficiency → formula can have an impact on performance
How will you build a working formula?
Family functions: Logical
● AND($User.ByP__c, a='ui', b=c, ...)
○ All statement should be true
○ Can be substituted with operator &&
● OR(a='ui', b=c, ...)
○ At least one statement should be true
○ Can be substituted with operator ||
● NOT(a='ui')
○ Returns the logical opposite
○ Can be substituted with operator !
Tips:
NOT(AND(A, B)) = OR(NOT(A), NOT(B)
OR(A, B) = NOT(AND(NOT(A), NOT(B)))
● IF(a='01', 'Yes', 'No')
○ Classical if statement
● CASE (a, '01'='One', ‘02’=‘Two', ... , 'N/A')
○ Nice substitute to multiple IFs
● BLANKVALUE(a, 'N/A')
● NULLVALUE(a, 'N/A')
● ISBLANK(a)
● ISNULL(a)
● ISNUMBER(a)
How will you build a working formula?
Family functions: Text
● BR()
● HYPERLINK('/'+$User.Id, 'Me')
● IMAGE('/img/start.png', 'start')
● INCLUDES(MultiPckLst__c, '01')
● ISPICKVAL(PckLst__c, '01')
● TEXT(n) text transform
● VALUE(t) number transform
● CASESAFEID(id15)
● LEN(t) length of a text
● LEFT(a, 3) MID(a, 1, 2) RIGHT(a, 1)
● LOWER(t) UPPER(t) case transform
● LPAD(t, 10, '0') left padding
● RPAD(t, 8, 'X') right padding
● TRIM(t) removes spaces around
● SUBSTITUTE(t, 'old', 'new')
● CONTAINS('oiu', 'o') = 1
● FIND('d', 'abcdef', 6) = 0
How will you build a working formula?
Family functions: Math
● ABS(-1) = 1
● CEILING(1.125) = 2
● FLOOR(1.525) = 1
● ROUND(47.4687, 2) = 47.47
● MAX(a, b, …)
● MIN(a, b, …)
● MOD(47, 3) = 2
● EXP(2) = e^2 = 7.38905609893065
● SQRT(4) = 2
● LN(19) = 2.9444389791664403
● LOG(10) = 1
How will you build a working formula?
Family functions: Date and Time
● WEEKDAY(date)
○ 1 = Sunday
● DAY(date)
● MONTH(date)
● YEAR(date)
● ADDMONTHS(date, number)
○ Takes care of February
○ Not just adding 30 days
● DATETIMEVALUE
● DATEVALUE
● TIMEVALUE
● NOW
○ Returns today’s datetime
● TODAY
○ Returns today’s date
● TIMENOW
○ Returns today’s time
● DATE(year, month, day)
● HOUR(datetime)
● MINUTE(datetime)
● SECOND(datetime)
● MILLISECOND(datetime)
How will you build a working formula?
Family functions: Advanced
● ISCHANGED(field)
● PRIORVALUE(field)
● ISNEW()
● ISCLONE()
● REGEX(field, '(.*test.*){3,}')
○ Validate complex formatting
● VLOOKUP(lookup.fieldA, lookup.fieldB,
fieldC)
○ Look in the table “lookup”
○ For record where lookup.fieldB = fieldC
○ Return the value of fieldA of the record
○ Limit of 10 per object (can be raised to
20 max with a case to SF support)
● $ObjectType.Obj.Fields.Fld
Part III
Examples
Examples
Using CONTAINS instead of multiple IFs or CASE
● Instead of a very long CASE(),
here we use CONTAINS with a
little trick.
● All values that have the same
result, are concatenated with a
separator “:”
● In this case, we do not indent to
have all the contains aligned but
we have multiple “)” at the end
Examples
Ultimate parent account
● Using Parent.Name to get the
Account FATHER’s name
● Using Parent.Parent.Name to
get the Account GRAND FATHER’s
● ETC…
● In formula no errors if lookups
are empty or null
● Starting at the 5th generation
● BLANKVALUE simulates that we
continue to check lower or not
● Limit: not up to 10 “generations”
Examples
Calculate “age”
● Subtract the current datetime
(with NOW) and a datetime field
(in the future)
● Result is the number of days.
● The result can have decimals
because time may not be aligned
Examples
Instead of a button, have a dynamic link
● Use HYPERLINK to create a link
● The URL of the link will contain a
static value and a dynamic
parameter
Examples
Check information on current User
● We use MAX to get fast the
maximum value over three values
● $User is used to get the value of
a custom field on the record of
the current user
Tips:
$User is also interesting to have ByPass for
Validation Rule or Workflow on the User level
Examples
Merging multiple fields into one with preference
● Using a picklist on the contact to
store the prefered way to call the
contact on the CTI
● We use CASE of course
● Concatenate with “&” a little
prefix and the prefered phone
value
Examples
Is this year a leaping year?
● Using MOD to check if an integer
is a multiple of 400, 100 or 4.
● Also YEAR on a date
Examples
Images to have a greater impact
● Using IMAGE to return an HTML
code of an image with URL and
title (for accessibility)
● The URL is dynamic depending on
the value of a field
Examples
You asked for it: Add 3 business days to today
● If today is Monday → next Thu. → +3
● If today is Tuesday → next Fri. → +3
● If today is Wednesday → next Mon. → +3+2
● If today is Thursday → next Tue. → +3+2
● If today is Friday → next Wed. → +3+2
● If today is Saturday → next Wed. → +3+1
● If today is Sunday → next Wed. → +3
Proposal #1:
/* In three days from Today */
TODAY() + 3 +
/* Cases where we have to skip days */
CASE(WEEKDAY(TODAY()),
/* Wednesday (4) */ 4, 2,
/* Thursday (5) */ 5, 2,
/* Friday (6) */ 6, 2,
/* Saturday (7) */ 7, 1,
/* Other */ 0
)
Proposal #2:
/* In three days from Today */
TODAY() + 3 +
/* If Saturday, we skip Sunday */
IF(WEEKDAY(TODAY()) =7, 1,
/* If Wed, Thu or Fri, we skip the WE */
IF(WEEKDAY(TODAY())>=4, 3,
/* If Sun, Mon or Tue, we skip nothing */
0))
WEEKDAY() Meaning... Expected
1 Sunday TODAY() + 3
2 Monday TODAY() + 3
3 Tuesday TODAY() + 3
4 Wednesday TODAY() + 3 + 2
5 Thursday TODAY() + 3 + 2
6 Friday TODAY() + 3 + 2
7 Saturday TODAY() + 3 + 1
Examples
You asked for it: Data quality Scoring
● Initial Score = 0
● If Industry picklist is set → + 1
● If Phone not blank → +1
● If Email not blank → +1
● If Title not blank → +1
● So minimum score is 0
● And maximum score is 4
Field “Score__c”:
IF(ISBLANK(TEXT(Account.Industry)), 0, 1) +
IF(ISBLANK(Phone), 0, 1) +
IF(ISBLANK(Email), 0, 1) +
IF(ISBLANK(Title), 0, 1)
Field “ScoreImage__c”:
IMAGE(
'/img/samples/stars_' &
TEXT(
FLOOR(
Score__c / VALUE($Label.SCORE_MAX) * 5
)
) &
'00.gif',
TEXT(Score__c) & '/' & $Label.SCORE_MAX
)
Examples
You asked for it: Fiscal Year condition
● Fiscal Year is from 1 August to 31 July
● What is the FY for a specific date on a
record?
● Examples:
○ 5 August 2020 → “2020”
○ 10 September 2019 → “2019”
○ 20 July 2021 → “2020”
○ 31 July 2029 → “2028”
○ 1 August 1847 → “1847”
Proposal #1
/* First date of FY is 1 August (08/01) */
TEXT(
YEAR(Closed_Date__c) +
IF(MONTH(Closed_Date__c) >= 08,
1, /* Date is in the current FY */
0 /* Date is in the previous FY */
)
)
Proposal #2
TEXT(
YEAR(Closed_Date__c) +
IF(
Closed_Date__c >=
/* First date of FY is 1 August (08/01) */
DATE(YEAR(Closed_Date__c), 08, 01),
1, /* Date is in the current FY */
0 /* Date is in the previous FY */
)
Part IV
Resources around
formulas
Resources around formulas
Trailhead (part 1)
● Beginners:
○ https://trailhead.salesforce.com/content/learn/modules/point_click_business_logic?trail_id=forc
e_com_dev_beginner
● Advanced:
○ https://trailhead.salesforce.com/en/content/learn/modules/advanced_formulas
● Projects:
○ https://trailhead.salesforce.com/en/content/learn/projects/customize-a-salesforce-object
○ https://trailhead.salesforce.com/content/learn/projects/improve-data-quality-for-a-cleaning-
supply-app?trail_id=learn-admin-essentials
● Formula in Reports:
○ https://trailhead.salesforce.com/en/content/learn/projects/rd-summary-formulas
Resources around formulas
Trailhead (part 2)
● Formula in Flows:
○ https://trailhead.salesforce.com/en/content/learn/modules/flow-builder
● Formula in Workflows:
○ https://trailhead.salesforce.com/en/content/learn/modules/workflow_migration
● Formulas and Limits (Cross Object Formulas):
○ https://trailhead.salesforce.com/en/content/learn/modules/process-design-without-
limits/process-design-without-limits-object
● Preparing DEV I includes Formulas as well :
○ https://trailhead.salesforce.com/content/learn/modules/platform-developer-i-certification-prep-
fundamentals-and-database-modeling/pd1-1-data-modeling-and-management
Resources around formulas
Great additional stuff (out of Trailhead)
● An awesome site to test your formulas: https://formulon.io/
● Need help on limits? Go to Formula Field limits and restrictions
● Ways to optimize you formulas: Tips to reduce your formulas (pdf)
● THE reference on success community: Steve Molis aka “Formula Ninja”
● Find the full Power of One concept
● More information about Cross Object Formula limits
● Full use case for the VLOOKUP method usage
● To raise a ticket to support for more VLOOKUP capability, go here
● Some Regular Expression examples
● For ALL formulas documentation please go here
Les formules et moi, ça fait 3!
Les formules et moi, ça fait 3!

Weitere ähnliche Inhalte

Was ist angesagt?

Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 
Architectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsArchitectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsDebasish Ghosh
 
C++ integer arithmetic
C++ integer arithmeticC++ integer arithmetic
C++ integer arithmeticarvidn
 
Shunting yard algo
Shunting yard algoShunting yard algo
Shunting yard algoToufiq Akbar
 
T03 a basicioprintf
T03 a basicioprintfT03 a basicioprintf
T03 a basicioprintfteach4uin
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arraysNeeru Mittal
 
Introduction_modern_fortran_short
Introduction_modern_fortran_shortIntroduction_modern_fortran_short
Introduction_modern_fortran_shortNils van Velzen
 
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMFINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMAmira Dolce Farhana
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of CompositionScott Wlaschin
 
programming fortran 77 Slide02
programming fortran 77 Slide02programming fortran 77 Slide02
programming fortran 77 Slide02Ahmed Gamal
 
Level-based Resume Classification on Nursing Positions
Level-based Resume Classification on Nursing PositionsLevel-based Resume Classification on Nursing Positions
Level-based Resume Classification on Nursing PositionsJinho Choi
 

Was ist angesagt? (18)

Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Architectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsArchitectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain Models
 
C++ integer arithmetic
C++ integer arithmeticC++ integer arithmetic
C++ integer arithmetic
 
Shunting yard algo
Shunting yard algoShunting yard algo
Shunting yard algo
 
Shunting yard
Shunting yardShunting yard
Shunting yard
 
T03 a basicioprintf
T03 a basicioprintfT03 a basicioprintf
T03 a basicioprintf
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Introduction_modern_fortran_short
Introduction_modern_fortran_shortIntroduction_modern_fortran_short
Introduction_modern_fortran_short
 
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMFINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEM
 
Lr4 math cad
Lr4 math cadLr4 math cad
Lr4 math cad
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of Composition
 
programming fortran 77 Slide02
programming fortran 77 Slide02programming fortran 77 Slide02
programming fortran 77 Slide02
 
Level-based Resume Classification on Nursing Positions
Level-based Resume Classification on Nursing PositionsLevel-based Resume Classification on Nursing Positions
Level-based Resume Classification on Nursing Positions
 
Use Excel Formulas
Use Excel FormulasUse Excel Formulas
Use Excel Formulas
 
Lr5
Lr5Lr5
Lr5
 
CHAPTER 2
CHAPTER 2CHAPTER 2
CHAPTER 2
 

Ähnlich wie Les formules et moi, ça fait 3!

lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptMard Geer
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptSourabhPal46
 
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101Federico Razzoli
 
#SalesforceSaturday : Salesforce BIG Objects Explained
#SalesforceSaturday : Salesforce BIG Objects Explained#SalesforceSaturday : Salesforce BIG Objects Explained
#SalesforceSaturday : Salesforce BIG Objects ExplainedAtul Gupta(8X)
 
How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2Federico Razzoli
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 
Python bible
Python biblePython bible
Python bibleadarsh j
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScriptT11 Sessions
 
IMPORTRANGE-1.pptx
IMPORTRANGE-1.pptxIMPORTRANGE-1.pptx
IMPORTRANGE-1.pptxKetanSehdev3
 
What SQL should actually be...
What SQL should actually be...What SQL should actually be...
What SQL should actually be...Open Academy
 
Database Design most common pitfalls
Database Design most common pitfallsDatabase Design most common pitfalls
Database Design most common pitfallsFederico Razzoli
 
The Ring programming language version 1.10 book - Part 100 of 212
The Ring programming language version 1.10 book - Part 100 of 212The Ring programming language version 1.10 book - Part 100 of 212
The Ring programming language version 1.10 book - Part 100 of 212Mahmoud Samir Fayed
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQLMahir Haque
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and reviewAbdullah Al-hazmy
 

Ähnlich wie Les formules et moi, ça fait 3! (20)

lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101
 
#SalesforceSaturday : Salesforce BIG Objects Explained
#SalesforceSaturday : Salesforce BIG Objects Explained#SalesforceSaturday : Salesforce BIG Objects Explained
#SalesforceSaturday : Salesforce BIG Objects Explained
 
How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2
 
Single table inheritance
Single table inheritanceSingle table inheritance
Single table inheritance
 
Clean code
Clean codeClean code
Clean code
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 
Python bible
Python biblePython bible
Python bible
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
Matlab Workshop Presentation
Matlab Workshop PresentationMatlab Workshop Presentation
Matlab Workshop Presentation
 
IMPORTRANGE-1.pptx
IMPORTRANGE-1.pptxIMPORTRANGE-1.pptx
IMPORTRANGE-1.pptx
 
What SQL should actually be...
What SQL should actually be...What SQL should actually be...
What SQL should actually be...
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Database Design most common pitfalls
Database Design most common pitfallsDatabase Design most common pitfalls
Database Design most common pitfalls
 
Refactoring
RefactoringRefactoring
Refactoring
 
The Ring programming language version 1.10 book - Part 100 of 212
The Ring programming language version 1.10 book - Part 100 of 212The Ring programming language version 1.10 book - Part 100 of 212
The Ring programming language version 1.10 book - Part 100 of 212
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 

Mehr von Doria Hamelryk

Salesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French GatheringSalesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French GatheringDoria Hamelryk
 
Apex for Admins Workshop
Apex for Admins WorkshopApex for Admins Workshop
Apex for Admins WorkshopDoria Hamelryk
 
Concours Trailblazers be Certified
Concours Trailblazers be Certified Concours Trailblazers be Certified
Concours Trailblazers be Certified Doria Hamelryk
 
+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 Features+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 FeaturesDoria Hamelryk
 
Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)Doria Hamelryk
 
Odaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPDOdaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPDDoria Hamelryk
 
Opportunity Management workshop
Opportunity Management workshopOpportunity Management workshop
Opportunity Management workshopDoria Hamelryk
 
A la découverte de pardot
A la découverte de pardotA la découverte de pardot
A la découverte de pardotDoria Hamelryk
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementingDoria Hamelryk
 
Gérer ses campagnes marketing
Gérer ses campagnes marketingGérer ses campagnes marketing
Gérer ses campagnes marketingDoria Hamelryk
 
10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 Features10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 FeaturesDoria Hamelryk
 
Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)Doria Hamelryk
 
Salesforce Import Tools
Salesforce Import ToolsSalesforce Import Tools
Salesforce Import ToolsDoria Hamelryk
 
Concours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswitConcours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswitDoria Hamelryk
 
Salesforce Starter Kit
Salesforce Starter KitSalesforce Starter Kit
Salesforce Starter KitDoria Hamelryk
 
Comment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications SalesforceComment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications SalesforceDoria Hamelryk
 
Comment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vieComment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vieDoria Hamelryk
 
Girls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupeGirls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupeDoria Hamelryk
 
Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019Doria Hamelryk
 

Mehr von Doria Hamelryk (20)

Salesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French GatheringSalesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French Gathering
 
Winter 22 release
Winter 22 releaseWinter 22 release
Winter 22 release
 
Apex for Admins Workshop
Apex for Admins WorkshopApex for Admins Workshop
Apex for Admins Workshop
 
Concours Trailblazers be Certified
Concours Trailblazers be Certified Concours Trailblazers be Certified
Concours Trailblazers be Certified
 
+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 Features+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 Features
 
Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)
 
Odaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPDOdaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPD
 
Opportunity Management workshop
Opportunity Management workshopOpportunity Management workshop
Opportunity Management workshop
 
A la découverte de pardot
A la découverte de pardotA la découverte de pardot
A la découverte de pardot
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementing
 
Gérer ses campagnes marketing
Gérer ses campagnes marketingGérer ses campagnes marketing
Gérer ses campagnes marketing
 
10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 Features10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 Features
 
Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)
 
Salesforce Import Tools
Salesforce Import ToolsSalesforce Import Tools
Salesforce Import Tools
 
Concours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswitConcours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswit
 
Salesforce Starter Kit
Salesforce Starter KitSalesforce Starter Kit
Salesforce Starter Kit
 
Comment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications SalesforceComment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications Salesforce
 
Comment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vieComment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vie
 
Girls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupeGirls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupe
 
Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019
 

Kürzlich hochgeladen

Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 

Kürzlich hochgeladen (20)

Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 

Les formules et moi, ça fait 3!

  • 1.
  • 2. Vincent Finet Senior Program Architect @ Salesforce twitter.com/VinceFINET linkedin.com/in/vincentfinet trailhead.com/me/vincefinet
  • 3. I II III Where do we found formulas in Salesforce? How will you build a working formula? Examples IV Resources around formulas Expert Starter Curious Middle
  • 4. Part I Where do we found formulas in Salesforce?
  • 5. Where do we found formulas in Salesforce? Location #1: Formula Fields ● Characteristics ○ At the Object level, like any other field ○ 8 different types ○ 1 formula expression ○ Value calculated on the fly (= not stored) ○ Cannot be indexed (unless deterministic + SF case) ○ Treat blank behavior (defined for each field) ● Restrictions: ○ Max number of characters: 3900 characters ○ Max formula size upon save: 4000 bytes ○ Max compiled size: 5000 bytes ○ Can’t reference: long text area, encrypted or description. ○ Cross-Object Formulas (across all fields of the same object): 15
  • 6. Where do we found formulas in Salesforce? Location #2: Validation Rules ● Characteristics ○ At the Object level ○ Data quality concerns ○ Can be activated or inactivated ○ Raise an error if a condition is met ○ Save is blocked if any error ○ Error message is raised on the top or on a field ● Restrictions: ○ Little mental gym when writing the formula because you specify the error condition and not the success condition ○ Launched only once (for example: not after a workflow field update)
  • 7. Where do we found formulas in Salesforce? Location #3: Workflows ● Characteristics ○ At the Object level ○ Automation concerns ○ Workflow rule: entering formula criteria ○ Workflow field update: new value formula ● Restrictions: ○ Old school automation but still robust!
  • 8. Where do we found formulas in Salesforce? Location #4: Process builders ● Characteristics ○ At the Object level ○ Automation concerns ○ Criteria with a boolean formula ● Restrictions: ○ Duplicate formula (leading to errors) if you have CASE like criterias
  • 9. Where do we found formulas in Salesforce? Location #5: Reports ● For a long time, formula in reports were VERY limited, so we had to create formula field to have formulas in reports ● Use case #1: Cross-Object formula ○ Limit of 15 per object on Formula Fields, WF Rules, WF Field Updates, Approval Processes, Validation Rules, Assignment Rules, Escalation Rules, and Auto-Response Rules ● Use case #2: Nice icons on report for scoring ○ Use of IMAGE() with standard icons ● Use case #3: “Power Of One”
  • 10. Part II How will you build a working formula?
  • 11. How will you build a working formula? The basics ● Literal value = 'test' = "test" = 0.4 = TRUE = true = TrUe ● Operator = FieldA__c & 'ooo' = (FieldA__c + 8)^2 / 100 ● Functions = AND(aa = 0, bb, ...) = TODAY() = ROUND(FieldA__c*0.02, 2) = HYPERLINK('/'+$User.Id) = IMAGE('/img/samples/flag_red.gif', 'red') ● Field reference = FieldA__c = FieldA__r.Name = Parent.Parent.Parent.Name = $CustomMetadata.MyCMDT = $Label.MyCustomLabel = $Organization.Id = $Profile.Name = $UserRole.DeveloperName = $User.Id ● Comment = /* Comment here */ = ROUND( /*:)*/ FieldA__c, /*;|*/ 3)
  • 12. How will you build a working formula? Best practices ● Multiple lines ● Indent ● Functions and keywords in UPPERCASE ● Add comments in the formula (if needed) ● Don’t hard code values, use custom labels instead ● Think reusable → multiple formulas instead of one ● Think maintenance → make the formula readable ● Think efficiency → formula can have an impact on performance
  • 13. How will you build a working formula? Family functions: Logical ● AND($User.ByP__c, a='ui', b=c, ...) ○ All statement should be true ○ Can be substituted with operator && ● OR(a='ui', b=c, ...) ○ At least one statement should be true ○ Can be substituted with operator || ● NOT(a='ui') ○ Returns the logical opposite ○ Can be substituted with operator ! Tips: NOT(AND(A, B)) = OR(NOT(A), NOT(B) OR(A, B) = NOT(AND(NOT(A), NOT(B))) ● IF(a='01', 'Yes', 'No') ○ Classical if statement ● CASE (a, '01'='One', ‘02’=‘Two', ... , 'N/A') ○ Nice substitute to multiple IFs ● BLANKVALUE(a, 'N/A') ● NULLVALUE(a, 'N/A') ● ISBLANK(a) ● ISNULL(a) ● ISNUMBER(a)
  • 14. How will you build a working formula? Family functions: Text ● BR() ● HYPERLINK('/'+$User.Id, 'Me') ● IMAGE('/img/start.png', 'start') ● INCLUDES(MultiPckLst__c, '01') ● ISPICKVAL(PckLst__c, '01') ● TEXT(n) text transform ● VALUE(t) number transform ● CASESAFEID(id15) ● LEN(t) length of a text ● LEFT(a, 3) MID(a, 1, 2) RIGHT(a, 1) ● LOWER(t) UPPER(t) case transform ● LPAD(t, 10, '0') left padding ● RPAD(t, 8, 'X') right padding ● TRIM(t) removes spaces around ● SUBSTITUTE(t, 'old', 'new') ● CONTAINS('oiu', 'o') = 1 ● FIND('d', 'abcdef', 6) = 0
  • 15. How will you build a working formula? Family functions: Math ● ABS(-1) = 1 ● CEILING(1.125) = 2 ● FLOOR(1.525) = 1 ● ROUND(47.4687, 2) = 47.47 ● MAX(a, b, …) ● MIN(a, b, …) ● MOD(47, 3) = 2 ● EXP(2) = e^2 = 7.38905609893065 ● SQRT(4) = 2 ● LN(19) = 2.9444389791664403 ● LOG(10) = 1
  • 16. How will you build a working formula? Family functions: Date and Time ● WEEKDAY(date) ○ 1 = Sunday ● DAY(date) ● MONTH(date) ● YEAR(date) ● ADDMONTHS(date, number) ○ Takes care of February ○ Not just adding 30 days ● DATETIMEVALUE ● DATEVALUE ● TIMEVALUE ● NOW ○ Returns today’s datetime ● TODAY ○ Returns today’s date ● TIMENOW ○ Returns today’s time ● DATE(year, month, day) ● HOUR(datetime) ● MINUTE(datetime) ● SECOND(datetime) ● MILLISECOND(datetime)
  • 17. How will you build a working formula? Family functions: Advanced ● ISCHANGED(field) ● PRIORVALUE(field) ● ISNEW() ● ISCLONE() ● REGEX(field, '(.*test.*){3,}') ○ Validate complex formatting ● VLOOKUP(lookup.fieldA, lookup.fieldB, fieldC) ○ Look in the table “lookup” ○ For record where lookup.fieldB = fieldC ○ Return the value of fieldA of the record ○ Limit of 10 per object (can be raised to 20 max with a case to SF support) ● $ObjectType.Obj.Fields.Fld
  • 19. Examples Using CONTAINS instead of multiple IFs or CASE ● Instead of a very long CASE(), here we use CONTAINS with a little trick. ● All values that have the same result, are concatenated with a separator “:” ● In this case, we do not indent to have all the contains aligned but we have multiple “)” at the end
  • 20. Examples Ultimate parent account ● Using Parent.Name to get the Account FATHER’s name ● Using Parent.Parent.Name to get the Account GRAND FATHER’s ● ETC… ● In formula no errors if lookups are empty or null ● Starting at the 5th generation ● BLANKVALUE simulates that we continue to check lower or not ● Limit: not up to 10 “generations”
  • 21. Examples Calculate “age” ● Subtract the current datetime (with NOW) and a datetime field (in the future) ● Result is the number of days. ● The result can have decimals because time may not be aligned
  • 22. Examples Instead of a button, have a dynamic link ● Use HYPERLINK to create a link ● The URL of the link will contain a static value and a dynamic parameter
  • 23. Examples Check information on current User ● We use MAX to get fast the maximum value over three values ● $User is used to get the value of a custom field on the record of the current user Tips: $User is also interesting to have ByPass for Validation Rule or Workflow on the User level
  • 24. Examples Merging multiple fields into one with preference ● Using a picklist on the contact to store the prefered way to call the contact on the CTI ● We use CASE of course ● Concatenate with “&” a little prefix and the prefered phone value
  • 25. Examples Is this year a leaping year? ● Using MOD to check if an integer is a multiple of 400, 100 or 4. ● Also YEAR on a date
  • 26. Examples Images to have a greater impact ● Using IMAGE to return an HTML code of an image with URL and title (for accessibility) ● The URL is dynamic depending on the value of a field
  • 27. Examples You asked for it: Add 3 business days to today ● If today is Monday → next Thu. → +3 ● If today is Tuesday → next Fri. → +3 ● If today is Wednesday → next Mon. → +3+2 ● If today is Thursday → next Tue. → +3+2 ● If today is Friday → next Wed. → +3+2 ● If today is Saturday → next Wed. → +3+1 ● If today is Sunday → next Wed. → +3 Proposal #1: /* In three days from Today */ TODAY() + 3 + /* Cases where we have to skip days */ CASE(WEEKDAY(TODAY()), /* Wednesday (4) */ 4, 2, /* Thursday (5) */ 5, 2, /* Friday (6) */ 6, 2, /* Saturday (7) */ 7, 1, /* Other */ 0 ) Proposal #2: /* In three days from Today */ TODAY() + 3 + /* If Saturday, we skip Sunday */ IF(WEEKDAY(TODAY()) =7, 1, /* If Wed, Thu or Fri, we skip the WE */ IF(WEEKDAY(TODAY())>=4, 3, /* If Sun, Mon or Tue, we skip nothing */ 0)) WEEKDAY() Meaning... Expected 1 Sunday TODAY() + 3 2 Monday TODAY() + 3 3 Tuesday TODAY() + 3 4 Wednesday TODAY() + 3 + 2 5 Thursday TODAY() + 3 + 2 6 Friday TODAY() + 3 + 2 7 Saturday TODAY() + 3 + 1
  • 28. Examples You asked for it: Data quality Scoring ● Initial Score = 0 ● If Industry picklist is set → + 1 ● If Phone not blank → +1 ● If Email not blank → +1 ● If Title not blank → +1 ● So minimum score is 0 ● And maximum score is 4 Field “Score__c”: IF(ISBLANK(TEXT(Account.Industry)), 0, 1) + IF(ISBLANK(Phone), 0, 1) + IF(ISBLANK(Email), 0, 1) + IF(ISBLANK(Title), 0, 1) Field “ScoreImage__c”: IMAGE( '/img/samples/stars_' & TEXT( FLOOR( Score__c / VALUE($Label.SCORE_MAX) * 5 ) ) & '00.gif', TEXT(Score__c) & '/' & $Label.SCORE_MAX )
  • 29. Examples You asked for it: Fiscal Year condition ● Fiscal Year is from 1 August to 31 July ● What is the FY for a specific date on a record? ● Examples: ○ 5 August 2020 → “2020” ○ 10 September 2019 → “2019” ○ 20 July 2021 → “2020” ○ 31 July 2029 → “2028” ○ 1 August 1847 → “1847” Proposal #1 /* First date of FY is 1 August (08/01) */ TEXT( YEAR(Closed_Date__c) + IF(MONTH(Closed_Date__c) >= 08, 1, /* Date is in the current FY */ 0 /* Date is in the previous FY */ ) ) Proposal #2 TEXT( YEAR(Closed_Date__c) + IF( Closed_Date__c >= /* First date of FY is 1 August (08/01) */ DATE(YEAR(Closed_Date__c), 08, 01), 1, /* Date is in the current FY */ 0 /* Date is in the previous FY */ )
  • 31. Resources around formulas Trailhead (part 1) ● Beginners: ○ https://trailhead.salesforce.com/content/learn/modules/point_click_business_logic?trail_id=forc e_com_dev_beginner ● Advanced: ○ https://trailhead.salesforce.com/en/content/learn/modules/advanced_formulas ● Projects: ○ https://trailhead.salesforce.com/en/content/learn/projects/customize-a-salesforce-object ○ https://trailhead.salesforce.com/content/learn/projects/improve-data-quality-for-a-cleaning- supply-app?trail_id=learn-admin-essentials ● Formula in Reports: ○ https://trailhead.salesforce.com/en/content/learn/projects/rd-summary-formulas
  • 32. Resources around formulas Trailhead (part 2) ● Formula in Flows: ○ https://trailhead.salesforce.com/en/content/learn/modules/flow-builder ● Formula in Workflows: ○ https://trailhead.salesforce.com/en/content/learn/modules/workflow_migration ● Formulas and Limits (Cross Object Formulas): ○ https://trailhead.salesforce.com/en/content/learn/modules/process-design-without- limits/process-design-without-limits-object ● Preparing DEV I includes Formulas as well : ○ https://trailhead.salesforce.com/content/learn/modules/platform-developer-i-certification-prep- fundamentals-and-database-modeling/pd1-1-data-modeling-and-management
  • 33. Resources around formulas Great additional stuff (out of Trailhead) ● An awesome site to test your formulas: https://formulon.io/ ● Need help on limits? Go to Formula Field limits and restrictions ● Ways to optimize you formulas: Tips to reduce your formulas (pdf) ● THE reference on success community: Steve Molis aka “Formula Ninja” ● Find the full Power of One concept ● More information about Cross Object Formula limits ● Full use case for the VLOOKUP method usage ● To raise a ticket to support for more VLOOKUP capability, go here ● Some Regular Expression examples ● For ALL formulas documentation please go here