You are on page 1of 40
@ FOCUSONFORCE Developer Fundamentals Given a scenario, identify common use cases and best practices for declarative versus programmatic customizations, including governor limits, formula fields, and roll-up summaries. Pree Sree eee and Certification Preparation (@ roousoyroRcE + Table of Contents © ‘ounulaticlas © ‘oxnsta tits scenarios (6 rocusoyrorce | Table of Contents © ssol-uosunmarticts © ‘ol-vn summary Field Creation © solvocount noe a ee) mm © sol-voMactioe © soluomin tive © Using Roll-Up Summary Fields Roll-Up Summary Field Limitations (@ rocusovrorce Table of Contents © 2oltUpsummary Field Scenarios (@ rocusovrorce After studying this topic, you should be able to: © entity the main features and use cases for declarative and programmatic customization Identify the declarative or programmatic solution for various simple and complex scenarios. Describe the capabilities, functions, operators, and use cases for formula fields Describe the capabilities, types, and use cases of roll-up summary fields and the considerations when using them (@ FocusovroRce @) ©. Introduction This topic identifies common use cases for declarative and programmatic customizations. Declarative tools are becoming more ‘advanced which minimizes the need to always build complex solutions Using programmatic tools. Different scenarios will be covered to determine what type of solution can be implemented, This takes into (© rocusoyroRce «| Declarative and Programmatic Customization Declarative Customization Declarative customization is possible using tools such as Process Builder, Flow Builder, Workflow fae a aoe Paces 51 Programmatic Customization For programmatic customization, ‘Apex, Visualforce or custom Lightning ‘components can be utilized, Clicks vs. Code Ifa declarative tool can meet a requirement, it should be preferred. If it's not possible to meet a requirement declaratively, code should be used. Simple Requirements For simple use cases, such as performing asimple record validation or updating a record automatically, declarative customization can be used. Complex Requirements For complex requirements, such as invoking aweb service or creating a sophisticated user interface, programmatic. customization can be used (@ roousovraRce 1 Customization Options (@ rocusoyroRcE Salesforce Customization Options ‘There are three main options for customizing the Salesforce platform. —_ _ —_ DzoW UN arnt) ore AU ® Use point & click tools that Install apps and Use coding skills and tools are available in the Setup components from the to develop solutions menu AppExchange Almost any feature or ‘The integrated tools are ‘® Solutions have been functionality can be automatically updated reviewed and proven and implemented or integrated GirngSslevorcerseae mayinidesippartand—& Moecontotanae.tity | cycles maintenance ‘© Simpler and quickerto build | Solutions already built (@ roousovrorce ° Process Automation Tools ler, Workflow, and Approvals are declarative tools that can be used to automate repetitive business processes, FEIINVOCABLE METHOD (Apex) Ges) eee re Poon EB WORKFLOW ens Cian (@ rocusoyroRce +0] Note On Terminology NOTE © Lightning Flow: The product name for process automation tools that includes Process Builder and Flow Builder © Flow butter: The declarative automation tool thatisusedo create lows © Flow: An automation application created using Flow Builder that may contain different types of actions to meet simple to complex requirements. flow depending on its type may be invoked from the Ul, a record change, scheduled job, platform event, process, or programmatically through Apex. (© rocusovronce " Note On Terminology =a NOTE pe eee tre ete orate nate reer eee eres a Process Builder: The declarative automation tool that is used to create processes and capable of performing logic that require multiple if/then statements. Dees eee an at erent ate eee ct eee eect pe eee eae (@ rocusoyroRce 2 Note On Terminology NOTE Workflow: The declarative automation tool used to create workflow rules to meet simple automation requirements that contain single i/then logic ° ‘Workflow Rule: Used to define one or more criteria that will rigger a workflow action, which is evaluated ‘when records are created or updated ° © Wiorkiow Acton: defined action to perform when aworkfow ule crterlalsmet sucht afield update ask eer ameter ee eae Sl (@ rocusovronce | Declarative Customization (@ FocusoyroRoE “ Declarative Customization Declarative customization refers to the use of clicks or drag-and-drop solutions to build or extend an application. © DECLARATIVE TOOLS “ SIMPLE REQUIREMENTS Declarative tools, in general, should be used ta meet simple requirements that donot i require complex logic or processing. ‘ SIMPLE SOLUTIONS Declarative customization offers quicker and simpler problem resolution and quick \e) turnaround in development cycles. (@ rocusovronce +s] Use Cases of Declarative Customization ‘Some of the common use cases of declarative customization are as follows: eTAVENs DECLARATIVE SOLUTION Display the sum or count of anumber of related Usea roll-up summary field records formula Display the averageofa number of related records Use rollup summary field together field Validate that a country code is a valid ISO code Usea validation rule that contains a function Ensure that areason is entered before closing an Usea validation rule opportunity Ensure that afield value has a valid format (eg, a Use the Regex function ina validation rule Social Security Number field) (@ roousovronce © Programmatic Customization Programmatic Customization Programmatic customization refers to the use of code to build or extend an application. PROGRAMMATIC TOOLS and Lightning Web Components. * COMPLEX REQUIREMENTS. Programmatic customization is generally used to meet complex requirements or when the logic required in an app is complex. “» USAGE CONSIDERATION Ifa declarative tool can meet a requirement quickly and easily, it should be preferred to Using programmatic customization. Pragrarmaticsltlons nSeestorce may ulize Apex, Visuaforce,AuraComponents, ummm (© rocusororce * Use Cases of Programmatic Customization ‘Some of the common use cases of programmatic customization are as follows Ez REQUIREMENT cna Createa custom web service Apex Createa custom email service Apex Create a complex validation Apex Createa custom user interface Visualtorce Create a report with a custom format Visualtorce Define custom navigation patterns Visualforce eo vexmems Ea Use Cases of Programmatic Customization itzeW aves Grea (Create a custom Ul tor Lightning Experience Extend the Salesforce app with custom functionality Build apps with sophisticated UI using CSS ‘Add client-side functionality in Lightning Experience ‘Override standard actions in Lightning Experience Bulld a sophisticated UI for a Lightning community (@ rocusovronce Lightning Component Lightning Component Lightning Component Lightning Component Lightning Component Lightning Component When to Use Programmatic Customization Programmatic customization can be used for the following: EXTENDED PLATFORM FEATURES Extend Salesforce functionality beyond what's possible through declarative customization CUSTOM USER EXPERIENCE Create a custom user experience that cannot| be built using any declarative tool COMPLEX REQUIREMENTS. Support complex business processes that are unsupported by the existing functionality CUSTOM FUNCTIONALITY =a ‘Add custom functionality such as acallout web service, email service, complex validation, etc. CUSTOM COMPLEX LOGIC Implement complex or custom transactional logic in an app that cannot be added using declarative customization (@ rocusovrorce Governor Limits (@ rocusovtonce Flaws and Dencace 1 Like Apex, a transaction that is invoked by a flow or process is subject to governor limits. When building solutions using these tools, the following limits should be considered, Deal) ie Total number of SOQl queriesissued. 100 queries Total number of records retrieved by SOQL queries 50,000 records Total number of DML statements issued 150 statements Total number of records processed as aresultof DMLstatements 10,000 records Maximum CPU time on the Salesforce servers 10,000 ms (6 rocusoworce a Additional Flow Considerations The following are some additional considerations when using flows in a solution. “© ELEMENT EXECUTION LIMIT. Pag ‘When an element is called in a flow, itis counted as 1 element execution, For example, a a Decision element i called once and a Loop element s called twice, So, the total element execution is 3, The maximum element executions allowed per flow interview is 2,000. “ DMLOPERATIONS Like DML statements inside for-loop statements in Apex, placing an Update Records element, {for example, inside a For Loop element in a flow should be avoided. “ FORMULA VARIABLES Creating complex formulas using formula variables should be avoided as this affects performance of the flow. (@ rocusovronce u Additional Process Considerations The following are some additional considerations when using processes in a solution. “© ONE PROCESS PER OBJECT ‘When a single master process is used for an object, actions are consolidated, more organized, and results in fewer actions, This design helps avoid hitting governor limits & COMBINE ACTIONS AVOID INFINITE LOOPS Ifa process creates a record, which triggers another process, and this triggered process updates a record that triggers the original process, the looping can hit governor limits (© rocusovroRce (@ rocusovrorce Declarative customization can be used for simple scenarios, while complex scenarios, in general, require the use of programmatic customization, Ee evenue Plies aed Cee Flow Automatically create a record Process Builder Simple and Complex Scenarios Apex Trigger Flow ‘Automatically update arecord Process Builder Apex Trigger Flow ‘Automatically delete a record Flow Apex Trigger =a (@ rocusoyroRce 2 Blvataes ied etaees ue Process an email toa case Configuration of Email-to-Case Email Handler in Apex Visualforce Page Createa custom report Report Builder Custom Lightning Component Schedule ajob Flow ‘Apex Scheduler Simple and Complex Scenarios Sharing Pile Manial Sh Share records Teams (Account Team, Opportunity ‘Apex Managed Sharing Team,etc),and more Validate a record Validation Rule Apex Trigger (@ rocusovronce Simple and Complex Scenarios Bltaes ae) eterna) Invoke an external web service (Outbound Message REST or SOAP Callout in Apex. Create a wizard that guides through cow Flow aprocess Apex/Visualforce Visualforce Page Conditionally display aform field Flow Custom Lightning Component Perform a business process before Flow ApexTrigger arecordis deleted poses (© rocusoyroRce Scenarios & Solutions (@ rocusovtorce Scenarios and Solutions SIMPLE SCENARIO DECLARATIVE SOLUTION The highest opportunity amount needs to be Aroll-up summary field of type MAX can be displayed on the related account, created on the Account object for this use case. COMPLEX SCENARIO ‘The opportunity with the highest amount in the org at the time an opportunity isbeing. ‘created needs to be displayed on thenew record. (© rocusoyroRce PROGRAMMATIC SOLUTION ‘An Apex trigger can be created on the Opportunity object to display the opportunity with the highest amount ina custom field. SIMPLE SCENARIO ‘Acustom field on related Contact records needs to be updated whenever an account is updated. COMPLEX SCENARIO ‘Acustom field on an unrelated record needs tobe updated whenever anew accountis created. (6 rocusovronce Scenarios and Solutions DECLARATIVE SOLUTION It is possible to update related records such as contacts using Process Builder. PROGRAMMATIC SOLUTION ‘An Apex trigger can be used to update a custom field on the unrelated record, Although, its also possible to create alow for this use case. ‘SIMPLE SCENARIO. ‘Anew section with new custom fields needs to be displayed on the Opportunity detail page. COMPLEX SCENARIO The existing Opportunity detail page needs to be replaced with a new highly customized page ‘that uses a different format (@ FocusoyroRce Scenarios and Solutions DECLARATIVE SOLUTION ‘The page layout of an object can be easily ‘customized to add anew section with custom fields PROGRAMMATIC SOLUTION ‘An existing detail page can be overridden with 2 Visualforce page that canbe customized according to requirements. Scenarios and Solutions SIMPLE SCENARIO ‘Auser requires a reportin tabular format, consisting of all the closed opportunities inthe system. COMPLEX SCENARIO A report with a custom format used by the business needs to be generated and rendered asa POF fileona page. (© rocusovroRce DECLARATIVE SOLUTION ‘The report builder can be used tocreatea ‘tabular report on a standard or custom object. PROGRAMMATIC SOLUTION Visualforce code can be used to generate a reportthat uses a custom format. Itcan be rendered as a PDF file as well. ou Scenarios and Solutions SIMPLE SCENARIO Allemails received by a business on a particular email account need to be convert edintocases. COMPLEX SCENARIO contact record needs to be created based on contact information in email messages received by a business. (@ roousovroRce DECLARATIVE SOLUTION ‘The standard Emall-to-Case functionality can be utilized for this use case. PROGRAMMATIC SOLUTION ‘Apex Email Service can be used for this use ‘case, ast allows the use of custom logic to process the contents of inbound email, Scenarios and Solutions SIMPLE SCENARIO ‘Arreason should be entered when an ‘opportunity is closed by auser. COMPLEX SCENARIO ‘Auser should only be able to update an account record if certain unrelated custom object records have been created. DECLARATIVE SOLUTION A validation rule can be created to ensure that ‘user enters a reason when an opportunity is closed PROGRAMMATIC SOLUTION ‘An Apex trigger can be used for validation _- based on complex logic. An error can be added to the record ifa certain condition is true. (@ rocusovroRce SIMPLE SCENARIO ‘A community page needs to be customized so. that it shows arreport chart. COMPLEX SCENARIO ‘Acommunity page needs todisplay ahighly interactive user interface that utilizes data from multiple objects in Salesforce. (@ roousovtonce Scenarios and Solutions DECLARATIVE SOLUTION Alightningomponentcaled'Report chart’ AIA ‘can be added directly to a community page using Experience Builder. PROGRAMMATIC SOLUTION ‘Acustom Lightning Component can be developed and added to the community page. SIMPLE SCENARIO In Lightning Experience, an area that allows users to enter text with custom font and size should be added to the Account record page. COMPLEX SCENARIO Is required for the Opportunity Experience. It should not have Salesforce Classic design elements. (© rocusoyroRce Scenarios and Solutions = DECLARATIVE SOLUTION ‘The Rich Text’ Lightning Component can be added to the record page using Lightning App Builder. PROGRAMMATIC SOLUTION ‘A custom Lightning component can be developed and added to the record page using Lightning App Builder. SIMPLE SCENARIO The Salesforce mobile appneedstohavea page that displays the Chatter Feed, COMPLEX SCENARIO Scenarios and Solutions DECLARATIVE SOLUTION / custom Lightning page containing standard Lightning components canbe created declaratively and added to the Salesforce app navigation menu, PROGRAMMATIC SOLUTION =a ‘Alistor opportunities tnat nave not been modified in the ast seven days needs to be displayed in the Salesforce app. (@ rocusovronce ‘Acustom Lightning component can be developed for this use case. A custom tab can be created for it and added to the navigation Scenarios and Solutions SIMPLE SCENARIO. Before an Opportunity record is deleted, a Log record needs to be created to track the deletion for audit purposes. COMPLEX SCENARIO ‘Arecord contains several URL fields, and the status code of each link needs to be stored in dedicated fields after the record is saved. (© rocusoyroRce DECLARATIVE SOLUTION Arecord-triggered flow can be created and configured torun before an opportunity is. deleted, and create alog and save any necessary information to it PROGRAMMATIC SOLUTION ‘An Apex trigger can be created to perform asynchronous HTTP callouts toretrieve the status code of each linkand save it to the necessary fields. Formula Fields (@ roousovraRce Formula Fields Formula fields are read-only fields that automatically calculate a value based on other fields, ‘expressions, of values. They can be used to prevent manual errors. o) changes. AUTOMATIC UPDATE, Formula fields are automatically updated when one of the fields referred in the formula LATEST DATA MERGE FIELDS ‘Aformula field calculates the latest data Led Merse fields can reference feds on related when itis viewed, and itcan be used in reports, [IB objects. For example, a formula field on and SOQL queries. [Contact can reference afield from Account. SUPPORT FUNCTIONS RETURN TYPES =a Different formula function categories are Jf Formula elds can be ofthe following types Date & Time, Logical, Math, Text, and Checkbox, Currency, Date, Date/Time, Advanced. Number, Percent, Text, or Time. (@ rocusonorce a Formula Fields Formula fields can be based on a simple formula or advanced formula. SIMPLE FORMULAS ‘Simple formulas allow selection of one or more fields and operators such as Add / Subtract / Concatenate. @ ADVANCED FORMULAS ‘Advanced formulas allow selection of one oF more fields, operators and { Set (@ rocusovronce « Creating a Formula Field ‘A formula field can be created by choosing the ‘Formula’ data type while creating a new custom field on an object. wc on Few Custom Field aT (@ rocusovrorce 4 Formula Return Types Available ‘The following highlights the return types available when configuring a formula field. ued |For Fd sane [ay Feman Fe) Soon ano ea) (@ rocusovronce | Simple Formula ‘The Simple Formula tab allows constructing a basic formula used to produce a value. Quick Tips Entor your formula and cick Chock Syrtax io check for rors. Cok the Advanced Formula sub to use addtional elds, operators, and functions, ee ‘Example: Full Namo = LastName &," FesiName) Moce Examples. ‘Simple Formule Advanced Formula Select Fel Type Insert Feld > [Account __v)[— insert Merge Field __v) nee Overmtor 7 ‘My Formula Feta (Tox) = eek Syrta (@ roousovrance «| Advanced Formula ‘The Advanced Formula tab provides more options such as additional fields, operators, and functions for defining a formula, ‘Simple Formula | Advanced Formula Functions Al Function IF (logical_test, value if true, value if false) —~nnael HYPERLINK iF IMAGE INCLUDES. near Salat Function Fogeal tot valve tue, lve # le) hack wha a condo is , eek yas landreuns one valu TRUE ond [mother vise # FALSE. (6 rocusoyronce 2 Checking for Errors ‘The Check Syntax button can be used to check for errors in the entered formula. If there is an error, itis displayed (@ rocusowonce « Cross-Object Formulas =a Accross-object formula can be used to reference data from parent objects. I il RELATIONSHIPS | Across-objectformulaused —Accross-object formula can Cross-object formulas inaformulafieldonachild reference elds from support referencing fields object can reference merge — master/parent objects are up _ from objects that arerelated | fieldsfromaparent object. | to 10 relationships away. ‘ther lookupor i i master-detalrelationships. (© rocusonrorce * Merge Fields ‘Amerge field is a field that can be used in a cross-object formula to incorporate values from the current record or a related record, Insert Feld ‘Sc tl nok ne ibe toed a ee are mo fall a (ieee rent | (@ rocusovrorce ‘| Formula Operators Listed below are different math, logical, and text operators that can be used in a formula field, ==] + (Add) = and = (Equal) '& (Concatenate) - (Subtract) <> and != (Not Equal * (Multiply) «(Less Than) ¢ (Divide) > (Greater Than) “ (Exponentiation) ‘<= (Less Than or Equal) (Parentheses) >= (Greater Than or Equal) ‘SE (AND) IH(OR) (© rocusoworce s Formula Field Functions Listed below are different functions in each category that can be used in a formula field. © DATETIME SADDMONTHS =» MINUTE *Ascil '* INCLUDES “= RIGHT * DATE = MONTH * BEGINS ‘ INITCAP “= RPAD. *DATETIMEVALUE —» NOW BR + ISPICKVAL, +» SUBSTITUTE * DATEVALUE * SECOND * CASESAFEID '* ISENCODE TEXT + DAY = TIMENOW * CONTAINS, ISINHTMLENCODE + TRIM * DAYOFYEAR «TIMEVALUE + FIND LEFT “+ UPPER * FORMATDURATION » TODAY *GETSESSIONID LEN * URLENCODE = HOUR © UNIXTIMESTAMP * HTMLENCODE + LOWER. = VALUE * ISOWEEK » WEEKDAY. HYPERLINK, = LPAD = ISOYEAR * YEAR + IMAGE =MID * MILLISECOND = =] Formula Field Functions ae re] SUMMARY & ADVANCED eau icdtecele = PARENTGROUPVAL ABs #106 ‘AND = PREVGROUPVAL = acos = MAX * BLANKVALUE = CURRENCYRATE. ASIN = MCEILING * CASE * GETRECORDIDS: “= ATAN = MFLOOR oF INCLUDE * ATAN2 MIN + ISBLANK ‘* ISCHANGED = CEILING *MoD + ISCLONE *JUNCHONIDUST unk . s1sNEW + LINKTO cos *PICKLISTCOUNT ——* ISNULL. “+ REGEX += DISTANCE ROUND, + ISNUMBER » REQUIRESCRIPT “EXP SIN NOT “ URLFOR “= FLOOR SORT + NULLVALUE *VLOOKUP ‘= FROMUNIXTIME «TAN OR = GEOLOCATION + TRUN + PRIORVALUE +N (@ rocusovrorce Use Cases of Formula Fields The following lists cases or scenarios where formula fields are commonly used. CONCATENATE VALUES concatenate operator. ACCESS PARENT FIELDS record, CROSS RELATIONSHIPS bt called a cross-object formula) (@ rocusovrorce CConcatenate the values of fields and strings using the ampersand (6) or Obtain the value of afield that belongs toa parent record from the child the value of a field from a related object (for example, object related through a lookup relationship) up to 10 relationships away (thisis Use Cases of Formula Fields CALCULATE DATES Perform date calculations such as, calculating the difference between dates, finding the month from adate, and adding days or months toa date. DISPLAY IMAGES Display images based on certain values. For example, traffic light indicator based on a certain field value. CONDITIONAL LOGIC Use conditional logic. or example, an IF statement to calculate values MATCH VALUES Determine a value froma set of values. For example, determining aregion from the billing state (© rocusonronce A Use Cases of Formula Fields DISPLAY LINKS URL based ona tracking number. Create a URL link based on afield value. For example, create a tracking. DISPLAY CURRENCY Caleulate commission amounts based on the value of other fields such as the user role and opportunity amount. FORMAT TEXT Remove formatting from afield value. For example, remove dashes from a phone number. DISPLAY ADDRESS Create a formatted address including spaces and line breaks based on a country value. (@ rocusovrorce Use Cases of Formula Fields CONVERT UNITS Perform conversions, such as temperature conversion or converting miles tokilometers. CONVERT CURRENCY Perform the conversion of a given currency to the corporate currency. ROUND NUMBERS, Round a numerical value up or down to the nearest integer. CALCULATE DATES ‘Add a number of months toa specific date. For example, End Date! can be calculated by adding’ Duration’ (in months) to Contract Start Date! (@ rocusovrorce ADDMONTHS Function Example The following formula uses the ADDMONTHS function to add months to a given date value. FamalaOpont ‘Elarpe Rena One = CoaDal7/ Mes Exes Sep Fema | Adana Fara enttonb oan = (@ rocusovrorce PUIDDERICVD ATE Bein ctinn Bunn runcuun cAampre Cunnene rne The formula below uses the CURRENCYRATE function to display the conversion rate for a given currency. oroeusnan imitations of Formula Fields =) The following are some of the most important limitations of formula fields. CHARACTERS afield can contain up to 3900 ters only, including spaces, return characters, and comments. FIELD DELETION Fields that are referenced ina formula field SEARCH — ey a [C488 cannot be deleted. Deletion requires Itis not possible to search a formula field using any type of search, such as global or sidebar search, removing the field from the formula, UNSUPPORTED FIELDS DEPENDENCY Formula fields cannot use long text area, ‘field value cannot depend on another encrypted or Description fields. formula that references it. =a (6 rocusovronce Formula Field Scenarios (@ FocusoyroRCE a Scenario and Solution @ SCENARIO ‘A project manager often needs to communicate with the primary contact associated wit ech project (custom objet) a @ ae ‘The mobile number and email address ofthis contact should be made available on the record details page of the project. SOLUTION The following cross-object formulas can be created: = Phone Formula Field: Phone (Text)= Contact__r-Phone Email Address Formula Field: Email (Text)= Contact__r.£mail (© rocusovroRce | Scenario and Solution @ SCENARIO =a Project managers would like to see the project ‘age'by the time itcompletes. Also, they want to view the computation of the total project commission using the project revenue and percent commission field. SOLUTION The following formula fields can be created Project Age in Days (Number) = DATETIMEVALUE (Date_Completed_c) -DATETIMEVALUE (createdDate) Project Commision (Currency) = Froject_Revenue — Ee) Scenario and Solution + Percent_Conmicion_ © SCENARIO chin, The following Status’ values should be displayed in the Project =] GQ ccxcbsedon he owing dened characterises =e Pending if Project Stageis'In Review’ Ft © Started - if Prnlart Stave ie'Ononine? a Concled- Project Stage Decne E_d N ‘Delivered - if Project Stage is ‘Completed’ (@ rocusoyronce a Scenario and Solution SOLUTION ‘Acustom formula field that references the Project Stage field values can be created. For example: Status (Tex REN rat to tie Status (Text) = 2 far moje sg “en, we 0, een Siete tie, =a (© rocusoneonce sl Scenario and Solution @ SCENARIO The Project Urgency Level should be assigned based onthe [i © Premium-Level 1 % Gold- Level2 % Silver Level3 % standard- Level 4 Demo- Level (@ rocussnronce os Scenario and Solution SOLUTION ‘custom formula field that returns a text or number and uses the ‘CASE’ function can be created. For example: Urgency Level (Number) = SE ( Client_type, "premium", 1, "cold", 2, "silver", 3, "standard", 4, "Demo", 5, 5) Roll-Up Summary Fields (@ rocusiyronce Roll-Up Summary Fields Availability Functions > Itcanonly be created on the Itcalculates the Sum, Min, Max master object ina master-detal value or Record Count of field relationship or on some standard So Record count ota Felationships such se 0} oa + Itcanbe added ike other cust Ona fields to page layouts, views, or ‘Account-Opportunity. reports. o Limitations +. Example Use Cases + Maxof 25 roll-up fields per object © Count then & Not available on lookup i) ae relationships (some exceptions for standard to standard i) * Display the highest potential relationships) revenue from opportunities Not available on certain types of ‘© Total the cost of products on an. formulafields| opportunity (@ rocusovronce Capabi ies of Roll-Up Summary Fields Koll-up summary tlelds are read-only tields that calculate summary data without code. , © © FIELD SUPPORT Itis avallable forall custom master-detail relationships and some standard relationships, such as Opportunity-Product or ‘Account-Opportunity. j @ CALCULATION It is calculated whenever any referenced detail record is saved. (@ rocusoyroRce Capabilities of Roll-Up Summary Fields ROLL-UP TYPES. ‘A roll-up summary field can calculate the: # sum Minimum © Maximum value of afield in arelated list Record count of arelated list for a specified child object (@ rocusovtonce es s ACCESSIBILITY Like any other field, itis available in: ® Pagelayouts © Related lists # Views @ Reports (@ rocusovrorce Capabilities of Roll-Up Summary Fields The definition of a roll-up summary field has three parts: 49) 1. SUMMARIZED OBJECT + The child object in a master- emrtemtn a Se (@ rocusovtonce Roll-Up Count Type (@ rocusovroRce 28 COUNT (Record Count) This roll-up type calculates the number of child records in the master-detail relationship. © EXAMPLE ~ It is possible to display the number of opportunities related to an account using a roll-up summary field on the Account object, (@ rocusovronce oo] Create New Custom Field: COUNT When creating a COUNT roll-up summary field, the summarized object must be defined and the roll-up type must be set to COUNT. An optional filter criteria can be added. =a =—~ This criteria allows the field to only ears sm ce be count opportunities that are not either Closed Won or Closed Lost stage. (© rocusonrorce “ Count Roll-up Type Field Example =a ‘The example below shows a rollup summary field that counts all related ‘Open’ opportunities of a particular Account. HH Service Console scnue voor vx (@ rocusovronce (@ rocusoyroRce | SUM This roll-up type calculates the sum of all values in a specific field on the records of a particular related object ‘ © EXAMPLE =a ‘The total expected revenue of al related Opportunities need to be displayed in the parent Account record, A roll-up summary field (SUM) canbe created on the Account object. (@ rocusovronce Create New Custom Field: SUM When creating a SUM roll-up summary field, the summarized object must be defined and the roll-up type must be set to SUM. An optional filter criteria can be added. = ‘Sour Sm Pea scone Sepsis Ree) Sc (6 rocusovroRce Expected Revenue Sum in Lightning Experience The Expected Revenue roll-up summary field on the Account record below sums the Expect Revenue ‘Amount values from the related Opportunity records. F BittingtonTextes Corp of America ‘toon J co | tow | tne |w Dette News fd Actity ety Chater © opment) fees renee omer, uringon fa Matera 5) — Otten aon Sa tegen a Seneca 9 (@ rocusovrorce s6| Roll-Up Max Type (@ roousoyroRcE a MAX This roll-up type calculates the highest value of a specified field on child records, © EXAMPLE For instance, ListPrice rom the Opportunity Product object canbe summarized onthe Opportunity object find the product withthe Ree eee Oe (roscoe a Create New Custom Field: MAX The following shows the configuration of a rollup summary field that displays the maximum List Prf value in the related list of Opportunity line items. SoS | asenanen ‘= ssa CaPass >] (@ roousoyroRce Maximum ist Price in Lightning Experience ‘The following shows the same roll-up summary field that displays the maximum List Price value found in the related Opportunity line items. ca a Breen : (@ rocusovroRce Roll-Up Min Type (@ FoousoyFoRcE MIN This roll-up type calculates the lowest value of a specified field on child records. © EXAMPLE For instance, List Price from the Opportunity Product object can be summarized on the Opportunity object to find the product with the lowest price related to an opportunity. (@ rocusovroRce | Create New Custom Field: MIN The following shows the configuration of a roll-up summary field that displays the mi value in the related list of Opportunity line items. Ee meee um ra tot Laas >) (@ roousovronce Minimum List Price Example The following shows the same roll-up summary field that displays the minimum List Price value found in the related Opportunity line items, ap Eterm Gonaater +e care T ‘Susiccwe ‘Sino Dl owen - (6 rocusoyroRce o Using Roll-Up Summary Field= FocuSoNFORCE ‘| Sample Use Case © SCENARIO Universal Training Institute is using Salesforce to track training classes, students who have shown interest in these classes, as well as students ‘who have registered. The data model consists of acustam abject called ih ‘Student’ which has a master-detall relationship with a custom object named ‘Class'on the master side. The institute would lke to track the number of students with each of the three statuses mentioned (Interested, Verbally Committed; and ‘Registeredt) and the actual revenue sum of the actual fees paid by al the students with the status of ‘Registered and Paid’) on the Class object. (6 roousoyroRce se Solution: Roll-Up Summary Fields in Lightning Experience =) The record detail page below uses roll-up summary fields to display the number of students that are interested, committed, or have registered for a course. Boo wae tev oe npn (@ rocusovronce Solution: Roll-Up Summary Fields in Salesforce Classic ‘The record detail page below uses roll-up summary fields that display information such as enrollees and revenue that a course generated. sa = — =” ae a (@ rocusovroRce Implications of Roll-Up Summary Fields Arolkup summary field can be created on any standard or custom object that is on the master side of a master-detail relationship. Some limitations are: PREVENTS CONVERSION, Itisnot possible to convert amaster-detall relationship into lookup relationship if there is roll-up summary field on the parent object. CANNOT BE USED AS THE ERROR LOCATION FIELD It is not possible to use aroll-up summary field as the Error Location field in a validation rule CANNOT BE USED ON AUTONUMBER FIELDS. Itis not possible to summarize Autonumber felds ina roll-up summary fel. CANNOT BE USED IN LEAD MAPPING Roll-up summary felds are not available for mapping lead fields of converted leads. (@ rocusovrorce Using Roll-Up Summary Fields in Standard Relationships Itis possible to create a roll-up summary field in the following standard relationships: ACCOUNT ‘Onthe Account object ‘tosummarize OPPORTUNITY Onthe Opportunity object to summarize CAMPAIGN ‘Onthe Campaign object to summarize Opportunity records Opportunity Product records Campaign Member records (@ rocusoyroRce xa Roll-Up Summary Field Limitations (@ rocusoironce 101 Limitations of Roll-Up Summary Fields Roll-up summary fields perform calculations on a set of detail records and display them on master records in a master-detail relationship. MASTER-SIDE ONLY ] The field can only be created on an object that ison the master-side of a ‘master-detail relationship. MAXIMUM NUMBER By default, the maximum number of roll-up summary fields allowed on each objectis 25 but users can contact Salesforce Support to increase it up 1040. LIMITED SUPPORT FOR STANDARD RELATIONSHIPS, Itis not supported for all standard relationships, (e ocusovronce 1 Limitations of Roll-Up Summary Fields CUSTOM LOOKUP yfeldareoat avalon cto lookup relator =a NO CROSS-OBJECT SUPPORT The field being rolled up cannot be a formula field that references afield on another object (eross-object field reference). NO DATE FORMULA SUPPORT ‘The field being rolled up cannot be a formula field that contain dynamic date functions such as NOW/) and TODAYO, |e rocusoyronce 109 Limitations of Roll-Up Summary Fields To overcome the limitations, the following can be used: AUTOMATION TOOLS: APEX TRIGGER Process Builder and Flow Buildercanbe | Rc An Apextrgger on various DML events on utilized in many scenarios, for example PMIDD tie child object can beused, records in alookup relationship. APEX CLASSES Batch/scheduled Apex can be used. APPEXCHANGE APP ‘Third-party tools such as Roll-up Helper can. be downloaded from the AppExchange. (@ roousovrance 104 Roll-Up Summary Field Scenarios (@ rocusovrorce 106 Scenario and Solution ® SCENARIO Acales manager needs the total number ofall elated property 4 GA 218 tbe splayed on the parent Account. On top ofthe shouldbe alerted everytime the total number increases. SOLUTION “& A‘COUNT’ type roll-up summary field can be created in the ‘Account object to summarize related properties. “© The roll-up summary field can then be used as criter ‘workflow rule with email alert action. (6 rocusovronce 108 Scenario and Solution SCENARIO Seat ene oeeetemartaer earner ea eens eerie ANG ss cist crue sears aacieaate eine ern @ SOLUTION ¢ A’SUM'type roll-up summary field can be created to aggregate Opportunity Amount field values. 4 AMIN’ type roll-up summary field can be created to aggregate Opportunity Created Date to get the earliest value, ¢ A’MAX type roll-up summary field can be created to aggregate Opportunity Created Date to get the latest value. (@ rocusovrorce or Scenario and Solution SCENARIO ‘ASales Manager needs to view the minimum property amount inthe parent Project record. Ifthe minimum amount falls below {$5 000, the project status must be updated to Pause-Property Needs Review value. SOLUTION A'MIN' type roll-up summary field can be created to aggregate Property Amounts and get the least value. *® The roll-up surnmary field can then be used as criteriain a workflow rule field update. rl (@ rocusovronce Learn More @ Tailhead Identity Tools to Build Your Aop © When should Use Apex © Roll-Up Summary Field © Taihezd—tmolement Roll-Up Summary Field @ Tahead—Use Formula Fields © Foroulas Quick Reference @ Examples of Advanced Formula Fields (@ rocusovrorce

You might also like