Loading

Create Roll-Up Summary Fields Utilizing Salesforce Flow

Udgivelsesdato: Sep 20, 2024
Beskrivelse

A roll-up summary field aggregates data from a child object to a parent object within a Master-Detail relationship. These fields can utilize functions such as COUNT, SUM, MIN, and MAX.

For instance, a roll-up summary field can be employed to display the total value (amount) of opportunities associated with a related account. Additionally, roll-up summary fields can incorporate filter criteria, allowing for the display of a total opportunity value specifically from won opportunities related to the account. It is important to note that roll-up summary fields are exclusively available for objects in a Master-Detail relationship and cannot be applied to those with a Lookup relationship.

Løsning

In this example, we will use a Salesforce Flow to explore how to calculate the Number of Records related to Master Records.  The use case here is to determine the Count of Cases related to an Account.

 

  1. Create a number field on the Account object. This field needs to have zero decimal places.
  2. Open Flow Builder. From Setup, in the Quick Find box, enter Flows, select Flows, and then click New Flow.
  3. Select Start From Scratch, then click Next.
  4. Select Record Triggered Flow then click Create.
  5. For the Object choose Account, select the Radio Button A record is created or updated.
  6. Leave the Entry Conditions as is.
  7. For Optimize the Flow, select Actions and Related Records.
  8. We need to get all the child records associated with a parent record. For this purpose, we need to use the Get Records element.
  9. Enter the Label and Name. For Object, choose Case.  Add the conditional requirement of the Account ID of the Asset record being {!$Record.Id}
    Screenshot 2024-09-19 at 2.37.34 AM.png 

  10. We also need to store all records in this element, which automatically creates a collection variable for us to use in the Flow.
    Screenshot 2024-09-19 at 2.38.55 AM.png 


  11. Next, we need to add a loop element to loop through the Case records. Here we can use the collection variable from the Get Records element mentioned previously.

    Screenshot 2024-09-19 at 2.43.31 AM.png 

  12. We now need to create a number variable designed to store the count of Case records. This variable should be configured to have zero decimal places.

    Screenshot 2024-09-19 at 2.47.33 AM.png 

  13. Using the number variable created earlier, we will employ an Assignment element to assign the count of assets associated with the account to this variable.

    Screenshot 2024-09-19 at 2.56.39 AM.png 
  14. Finally, we need to add an Update Records element to the Flow after the Flow loop. This element should update the field on the Account record by assigning it the value of the 'CaseCount' number variable, which we have already set within the Flow.

    Screenshot 2024-09-19 at 3.00.24 AM.png 

    At this point, your final flow should resemble the following structure:
    Screenshot 2024-09-19 at 3.01.06 AM.png 


  15. Save and activate the Flow.
Yderligere ressourcer

Build a Flow

Trailhead - Meet Flow Builder

Vidensartikelnummer

002722670

 
Indlæser
Salesforce Help | Article