Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 36 ยท Projects and Practice

Project: Lead Assignment and Opportunity Automation

A complete Salesforce admin project: score and route leads, convert them, create follow-up tasks, and report on the funnel. Includes requirements, design, build steps and JavaScript stand-ins.

In this project you act as the administrator of a software company, Northwind Cloud, whose sales team complains that leads sit untouched for days, high-value deals are not noticed, and managers cannot see where the funnel leaks. You will design and describe the complete solution in Salesforce: lead scoring, assignment, conversion, follow-up automation, validation and reporting. You cannot build it on this site, so the lesson gives the requirements, the design decisions, the exact configuration steps and runnable JavaScript stand-ins that let you test the logic before you build the real thing. All stand-ins are labelled and are not Salesforce.

The requirements

  1. Leads from the web form get an owner within a minute, by region and size.
  2. Every lead gets a score from 0 to 100 (company size, title, source, engagement).
  3. Hot leads (score of 70 or more) create a task for the owner, due the next business day, and notify the sales manager.
  4. Leads not touched within 2 days are reassigned or escalated.
  5. Sales reps convert qualified leads to an account, a contact and an opportunity, with required fields enforced.
  6. Managers see a funnel report and a dashboard with leads by source, conversion rate and average time to first touch.

Step 1: data model

Add custom fields to Lead (Setup, Object Manager, Lead, Fields and Relationships):

Field Type Purpose
Lead_Score__c Number (3, 0) Score from 0 to 100
Employee_Band__c Picklist (1-10, 11-50, 51-200, 201+) Size without typing
First_Touch_Date__c Date/Time When a rep first contacted the lead
Hot_Lead__c Formula (Checkbox): Lead_Score__c >= 70 A filter-friendly flag
Region__c Picklist (Americas, EMEA, APAC) Routing key

Mark fields required on the layout only where the process needs them, and add validation rules, for example: Status cannot be "Qualified" without a Phone or Email:

TEXT
AND(ISPICKVAL(Status, "Qualified"), ISBLANK(Phone), ISBLANK(Email))

Map the lead fields to the account, contact and opportunity fields so that lead conversion keeps the data (Setup, Object Manager, Lead, Fields and Relationships, Map Lead Fields). Add Opportunity custom fields only after checking the mapping rules: custom lead fields map to custom fields of the same type.

Step 2: the score

For a first version, compute the score with a before-save record-triggered flow (Lead, created or updated; fast field updates), so there is no second save. Use a Formula resource or a set of Decision and Assignment elements that add points. A transparent rule set is better than a clever one: reps must understand why a lead scored 85.

Example points: Employee band 201+ (30), 51-200 (20), 11-50 (10); title contains "VP", "Head" or "Director" (25); source Partner Referral (20) or Webinar (10); email domain not a free provider (10); requested a demo (15). Cap the sum at 100.

JS Stand-in: lead scoring rules

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Step 3: assignment

Use lead assignment rules (Setup, Lead Assignment Rules) for routing, or a record-triggered flow for more complex logic, such as round-robin. A rule is an ordered list of entries; the first matching entry assigns the lead to a user or a queue. Remember to tick Assign using active assignment rules on web-to-lead and in the Data Loader if you want them applied.

Design the entries: Region = EMEA and Employee band 201+ to the EMEA Enterprise queue; Region = Americas to the Americas SDR queue; and a catch-all entry last that assigns to the Unassigned Leads queue so nothing falls through. Queues need members and email notification to the queue.

A round-robin needs a counter: store the last assigned index in a custom setting or a custom object and update it in the flow; take care with concurrent leads (two leads in one batch). Alternatively, use a queue and let reps claim leads, a simpler solution.

JS Stand-in: assignment rules and round-robin

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Step 4: hot lead follow-up (after-save flow)

Build a record-triggered flow on Lead, after save, run when a record is created or updated to meet the condition Hot_Lead__c = true. Elements: Get Records the lead's owner's manager (skip if none), Create Records a Task (Subject "Call hot lead: {!$Record.Company}", Due Date TODAY() + 1 adjusted to a weekday, Owner {!$Record.OwnerId}, WhoId {!$Record.Id}), then an Action to send an email alert to the manager. Add a Fault path that creates an Error Log record (Flow errors, debugging and testing). Because the entry condition is "becomes true", editing a hot lead later does not create duplicate tasks.

Step 5: stale lead escalation (scheduled flow)

A schedule-triggered flow runs daily at 07:00 on Leads where Status = "Open - Not Contacted" and CreatedDate < LAST_N_DAYS:2 and First_Touch_Date__c = null. For each match (collection and loop, one update at the end), set the owner to the Unassigned Leads queue or the next rep and create a task for the manager. Keep it bulk-safe (Loops, collections and limits).

JS Stand-in: stale lead scan

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Step 6: conversion

Reps click Convert on the lead. Configure: Lead Process, Lead Status values for converted, and the page layout showing the conversion button. Decide whether conversion creates an opportunity (usually yes), and whether it matches existing accounts and contacts (it will suggest them; check for duplicates, see Duplicates and data quality). Write a validation rule on Opportunity requiring CloseDate and Amount when the stage moves beyond Qualification.

Step 7: reporting

Create a custom report type Leads with converted-lead information, or use the standard Leads with converted lead information. Reports to build:

  1. Leads by Source and Status: summary, grouped by source then status, with record count.
  2. Funnel: Leads created, converted, opportunities, won (a joined report or a dashboard funnel).
  3. Time to first touch: a row-level formula First_Touch_Date__c - CreatedDate (hours), averaged by owner.
  4. Hot leads not yet contacted: filter Hot_Lead__c = true and First_Touch_Date__c is blank.

Put them on a Sales Leadership dashboard with filters for Region and Owner; a dynamic dashboard shows each manager their own team. See Dashboards and components.

JS Stand-in: funnel and conversion rate

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Step 8: test and release

Build in a Developer sandbox, test with 200 leads loaded by the Data Loader, test as a rep and a manager, then deploy (Change sets and deployment) after validating in production. Document the scoring rules, assignment entries and flows in a one-page runbook.

flowchart LR
  W["Web-to-Lead"] --> S["Before-save flow: score"]
  S --> A["Assignment rule"]
  A --> H{"Hot lead?"}
  H -->|"Yes"| T["After-save flow: task and manager alert"]
  H -->|"No"| Q["Normal queue"]
  Q --> D["Daily flow: stale lead escalation"]
  T --> C["Rep converts the lead"]
  D --> C
  C --> O["Account, contact, opportunity"]

The whole design on one page.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why score leads in a before-save flow?

    Before-save flows set fields on the triggering record efficiently, with no second save.
  2. 2. What should the last entry of a lead assignment rule be?

    A catch-all ensures that no lead is left without an owner.
  3. 3. How do you avoid creating a second task when a hot lead is edited later?

    The flow then runs only when the lead becomes hot.
  4. 4. Where should the Update Records element sit in the stale-lead flow?

    One update after the loop keeps the flow within governor limits.

Summary

  • You designed a lead-to-opportunity process: data model, score, routing, follow-up, escalation, conversion and reporting.
  • Use before-save flows for same-record changes, after-save flows for tasks and alerts, and scheduled flows for time-based checks.
  • Test the logic with 200 records, as different users, in a sandbox before deploying.
  • Document the rules so the business can understand and change them.

Next: Project: support desk setup