Sub topic 3
Getting leads into Salesforce
This chapter covers the ways a lead record gets created: manual entry, file imports, Web-to-Lead, and code. It assumes you can use Setup and the Object Manager, know what the Lead object holds, and have seen the Lead Status and Lead Source picklists from the earlier chapters. Each method differs in volume limits, in whether it runs assignment rules, and in how much cleanup it needs afterward. You need to know those differences to choose a method and to debug leads that land with the wrong owner or the wrong data.
The capture paths at a glance
Every lead is created through one of a few doors. The door decides which defaults apply, who the owner is, and whether the active assignment rule runs.
The decision node is the part to remember. Creating a lead and assigning it by rule are two separate steps. The next chapters cover how rules are built and triggered. Here, the question for each path is whether it asks for a rule.
| Path | Typical volume | Assignment rule runs? | Best for |
|---|---|---|---|
| Manual entry | One at a time | Only if the option is selected | Leads from calls, events, referrals |
| Data Import Wizard | Up to 50,000 records per import | Option in the wizard | Admin-run list uploads |
| Data Loader or API | Large batches | Only if you specify a rule | Migrations, integrations, scheduled loads |
| Web-to-Lead | Up to 500 new leads per 24 hours | Yes, the active rule | Public website forms |
| Apex | Within governor limits | Only with `DMLOptions` | Custom intake logic |
Manual entry
A user clicks New on the Leads tab, fills in the page layout, and saves. Two fields are required by default: Last Name and Company. If your org uses Person Accounts, Company is not required, but most orgs that sell to businesses keep it required.
If you leave the owner untouched, the creating user becomes the owner. Two things commonly surprise people here:
- The option to assign using the active rule is a checkbox on the lead form, and it must be available on the page layout. If the box is missing or unchecked, the lead stays with the creator.
- A default Lead Status is applied from the picklist value marked as default, so a new lead is never created without a status unless you override it.
Manual entry is fine for low volume, but it relies on discipline. Required fields and validation rules are the only guardrails, so keep the required set small enough that reps do not invent values just to save the record.
Importing leads from a file
Data Import Wizard
The Data Import Wizard is a guided tool in Setup. You upload a CSV, map columns to Lead fields, and run the import. It suits admins loading trade-show lists or purchased lists of moderate size. Its main limits are 50,000 records per import and a smaller set of supported objects than Data Loader.
A minimal CSV for leads looks like this:
FirstName,LastName,Company,Email,LeadSource,Status
Ada,Lovelace,Analytical Engines Ltd,[email protected],Web,Open - Not Contacted
Grace,Hopper,Compiler Works,[email protected],Trade Show,Open - Not ContactedCheck these before you click Start Import:
- Picklist values in the file must match your org's values exactly, including spacing and capitalization. A restricted picklist rejects values it does not know.
- Choose how to handle duplicates. The wizard can match existing leads by name, email, or Salesforce ID, and you decide whether to add only new records, update existing ones, or both.
- Decide whether to assign leads with the active assignment rule. If you skip this, every imported lead is owned by the importing user.
- Include a Lead Source column or set the value in the file. A blank Lead Source makes later conversion reporting much less useful.
Data Loader and the API
Data Loader is a client tool for large inserts, updates, and upserts. It calls the same API your integrations use. It handles far more records than the wizard and can run from the command line on a schedule. Two practices matter for leads:
- Use an external ID field to upsert, so reruns update existing leads instead of creating duplicates.
- To apply assignment rules, set the assignment rule option in Data Loader's settings, or send the rule header in your own API calls. Without it, the API inserts the lead with whatever owner you supplied, or with the integration user as owner.
After a load, check the result files. Data Loader writes success and error CSVs, and partial failures are common when a few rows break a validation rule.
Web-to-Lead
Web-to-Lead creates a lead when someone submits a form on your public website. Salesforce generates the HTML, and you paste it into your site. No login is needed, which is also why you must protect the form from spam.
Setup steps
- In Setup, go to Web-to-Lead and select Enable Web-to-Lead.
- In Lead Settings, choose a Default Lead Creator. This user becomes the creator of every web lead and receives error notifications. It should be an active user that will not be deactivated when someone leaves.
- On the Web-to-Lead page, click Create Web-to-Lead Form. Select the fields to include, choose a Return URL for the thank-you page, and generate the HTML.
- Optionally choose reCAPTCHA. The generated code then includes a verification step.
- Test the form with a unique email, then confirm the lead appears with the expected source, status, and owner.
What the generated form contains
The generated code posts to Salesforce's servlet. The sample below is trimmed to the essentials. Replace the oid value with your own 15- or 18-character org ID, and the retURL with your thank-you page.
<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type="hidden" name="oid" value="00D000000000000">
<input type="hidden" name="retURL" value="https://www.example.com/thanks">
<label for="first_name">First name</label>
<input id="first_name" name="first_name" maxlength="40" type="text">
<label for="last_name">Last name</label>
<input id="last_name" name="last_name" maxlength="80" type="text" required>
<label for="company">Company</label>
<input id="company" name="company" maxlength="40" type="text" required>
<label for="email">Email</label>
<input id="email" name="email" maxlength="80" type="email">
<input type="hidden" name="lead_source" value="Web">
<input type="submit" value="Submit">
</form>A few details explain most Web-to-Lead problems:
- The hidden
lead_sourcefield lets you tag leads by form. You can use different values on different pages to compare channels. - Custom fields appear in the form with generated IDs as names, such as
00N.... If you rebuild the form by hand, copy these IDs from the generator, because the names are not the API names. - The form can only set fields that exist on the Lead object and that you included. It cannot set the owner directly. Owner comes from the active assignment rule, or from the default if no rule entry matches.
- For debugging, you can add hidden
debuganddebugEmailfields. Salesforce then emails you the submission details. Remove them before launch.
Limits and failure modes
Other failure modes to plan for:
- Spam and bots. Public forms attract junk. Use reCAPTCHA and consider a hidden honeypot field you can filter on.
- Silent field mismatches. If the form sends a value that a restricted picklist does not accept, or a string longer than the field allows, the lead can fail to save. The Default Lead Creator is the person who gets the error notice, so make sure that mailbox is monitored.
- Duplicates. The same person submitting twice creates two leads unless a duplicate rule blocks or flags the second one. Set up a duplicate rule for leads and test it with the form, not only in the UI.
- Wrong owner. Web leads run the active assignment rule. If no entry matches, the lead falls to the default owner configured in Lead Settings. A pile of web leads under one name usually means the rule entries have a gap.
Creating leads from Apex and integrations
Code can insert leads from custom intake services, scheduled jobs, or other systems. The key point is that a plain insert does not run assignment rules. You must request them with DMLOptions, as shown in the Apex example in the chapter on triggering rules. Integrations built on the REST or SOAP API follow the same logic: the rule runs only if the request includes the assignment rule header.
Verifying what arrived
After any bulk load or campaign, query the leads to confirm that source, status, and ownership match your expectations:
SELECT LeadSource, Status, COUNT(Id) total
FROM Lead
WHERE CreatedDate = TODAY
GROUP BY LeadSource, Status
ORDER BY COUNT(Id) DESCRun this in the Developer Console Query Editor or any SOQL tool. A row with a blank LeadSource points to a form or file column that was never mapped. To check ownership, add Owner.Name to a non-aggregate version of the query and look for leads owned by the integration user or the Default Lead Creator.
Choosing a capture method
- Use manual entry for leads that start with a human conversation, and keep the required fields minimal.
- Use the Data Import Wizard for occasional, moderate lists that an admin can review before and after.
- Use Data Loader or the API when you need repeatable loads, external-ID upserts, or volumes beyond the wizard.
- Use Web-to-Lead for simple public forms under the 500-per-day cap, and plan for spam and monitoring.
- Use Apex or an integration when you need custom validation, enrichment, or routing at creation time.
Whichever you pick, set Lead Source consistently and decide up front whether assignment rules should run. Fixing owners and sources after thousands of records exist is much harder than setting them correctly at capture.
Exercise
A marketing campaign sends 800 visitors to a page with a Web-to-Lead form in one day. Afterward, Salesforce shows only about 500 new leads from that form, and no errors appear on the website. What is the likely cause, and what are two ways to avoid it next time?
Show answer
Web-to-Lead accepts at most 500 new leads per 24 hours, and later submissions are not saved as leads. The website does not show an error. To avoid losing prospects, use an API-based integration or a marketing automation tool that is not subject to this cap, or split the load by moving some capture to another method such as a scheduled Data Loader or API insert from a form backend.
Exercise
An admin imports 2,000 leads with the Data Import Wizard. Afterward, every lead is owned by the admin, even though an active assignment rule routes leads by country. What went wrong, and how would you fix the existing records?
Show answer
The import did not request the active assignment rule, so each lead kept the importing user as owner. For existing records, reassign them by re-running the import as an update with the assignment rule option selected, or use a Data Loader update with the assignment rule specified. For future imports, select the option to assign using the active rule before starting.