The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Recommended

Mining OpportunityHistory with pandas to see how sales really run before automating (opens in a new tab)

You will learn how to turn the OpportunityHistory object into an event log and use pandas to find stage variants, skipped stages, waiting times and single-person bottlenecks.

Why read this

You will also see what these findings should settle before an AI agent is given the sales process.

  1. Export OpportunityHistory as an event log
  2. Build stage variants and count rework
  3. Measure median wait between stages
  4. Count who moves the stages
The four analyses used to measure the real sales process from OpportunityHistory

The author argues that a documented sales process often differs from the one a company actually runs, and that an AI agent will faithfully follow whichever version it is given. Before automating, teams should measure the real process. Salesforce already records a row in OpportunityHistory whenever an opportunity’s stage, amount or close date changes, so no setup is needed. A SOQL query selecting the opportunity ID, stage, amount, close date, creation date and creator over the last 180 days can be exported to CSV and used as an event log.

The post then walks through four analyses in pandas. The first removes rows that are not real stage changes and counts the distinct stage paths, or variants, across opportunities; the documented process is usually one line, while the data usually shows many. The second flags opportunities that went back to an earlier stage and those that moved from creation to the last stage in two steps or fewer, which suggests the CRM was updated only at the end. The third calculates the median wait between each pair of stages to locate handoffs or approvals that happen outside the system. The fourth counts how many stage changes each user made, since one or two users moving most records suggests updates are being collected elsewhere and typed in.

The author stresses that these numbers show where the problems are, not why they occur. Each signal should prompt a question: which process is the real one, what the rep gains from updating the CRM, which area owns a slow handoff, and where the information actually lives. Answering these first prevents an agent from speeding up the wrong steps. The same approach can extend to orders, invoices and payments when the ERP lives in the same Salesforce org.

Read the original at dev.to (opens in a new tab)

Worth reading?

Checking Contact parent accounts after a Salesforce data migration (opens in a new tab)

You will learn why matching field values is not enough to verify a migration, and how to test each Contact's parent Account through a stable external key, using either pandas or Google Sheets formulas.

  1. Source Contact to its source Account ID
  2. Source Account ID to its stable key
  3. Target Contact to its target Account ID
  4. Compare the two Account keys
The check follows each Contact's parent Account through the stable key to the target org

A Contact can keep its name and email after a migration and still be attached to the wrong Account. Comparing field values will not catch this, and record IDs usually change between orgs, so they cannot be compared directly either. The article proposes a stable key, such as an External ID field, that identifies the same Account in both exports. The check follows the Contact’s source Account to its key, then confirms that the target Contact’s Account has the same key.

The article works through a small set of invented example CSVs. A pandas script merges the Contacts, maps each parent through the keys, and flags a WRONG_PARENT result for one Contact whose target Account points to the wrong record. The same logic is then rebuilt as Google Sheets formulas using INDEX and MATCH, with uniqueness checks on the keys and an EXACT comparison because MATCH is case-insensitive.

The author notes practical cautions for real exports. Lookups that return errors should be investigated rather than hidden with IFERROR, and the ranges must be widened for larger files. The check only verifies the relationships in the files loaded, so it does not certify a whole migration.

Read the original at dev.to (opens in a new tab)

Worth reading?