Our Use Case: Sum Up Relative Purchases for All Accounts

As explained briefly in prior videos, we’d like to simulate a report we created in Analytics using Deluge in the CRM.

It’s nice to have a report that summarizes data in Analytics, but even better if we can host that data in the CRM and maybe even sync it to apps like Campaigns where we can put it to great use.

So, our goal is to, at the Account level, regularly update a field for “Total Closed Revenue in the Last 12 Months.”

  • This is a moving target and so we need a scheduled function to run (at least weekly).
  • The function needs to pull data from the Deals and Accounts modules, add up all the Deal Amounts for Closed Won deals in the last 12 months, and then update the corresponding account.
  • Thus, the criteria in our search query is:
    – Deal stage is ‘Closed Won’
    – Closing Date is in the last 12 months (365 days)
  • At the same time, we need to order/group deals by account so that we can aggregate up the Amounts and update the right account record

To do all this, we will use a COQL query! We’ll map out exactly how it works in the next topic.

Back to Lesson