A lookup filter restricts which records a user can pick for a lookup field, and most test data generators have no idea that restriction exists. They grab a random Account, a random Contact, a random Asset, and insert. If the filter says "Account must be active and owned by the Support queue," a randomly chosen Account fails that check about half the time. The record either bounces back with an error or, worse, the filter silently lets a bad reference slip through in a test context where validation got disabled. Neither outcome tells you anything useful about whether your org actually works.
SproutEzee handles this by reading the lookup filter definition straight from the schema, the same place it reads field types, required flags, and picklist values. It does not guess. It parses the filter criteria, resolves the fields involved, and generates child records that reference only parent records satisfying those criteria. That is the whole problem solved at the source instead of patched after the fact.
Why Lookup Filters Break Random Test Data Generation
Lookup filters exist to keep users from picking the wrong record. A Case lookup to Asset might require the Asset to belong to the same Account as the Case. A Contract lookup to Contact might require Contact.Status equals Active. These rules live in the field metadata, not in a validation rule, which means a lot of generic data tools never even check for them. They read the field as "lookup to Contact" and stop there.
That gap matters more than it looks. Filtered lookups show up constantly in sales and service orgs: Opportunity to Contact Role filtered by account match, Case to Contact filtered by status, Quote Line to Product filtered by price book. Skip the filter and your generated dataset is full of relationships a real user could never create through the UI. Any test that exercises picker behavior, filter logic, or downstream automation keyed off that lookup is now running against data that is structurally impossible in production.
I have seen teams work around this by disabling the lookup filter in the sandbox before loading data, then forgetting to turn it back on before the next QA cycle. It works until someone ships a change that depends on the filter actually firing, and nobody notices because the filter has been off for three sprints. That is not a testing strategy. It is a time bomb with a polite UI.
How SproutEzee Reads Filter Criteria From Schema
Salesforce stores lookup filter definitions as part of the field describe metadata, including the filter type (required, optional, or filtered picklist-style), the boolean filter logic, and each filter item's field, operator, and value. SproutEzee pulls this during its schema scan, right alongside required fields and picklist constraints, so the generation engine knows about the filter before it writes a single record.
From there it builds a qualifying set. For a static filter, like "Status equals Active," it tags parent records that meet that condition and draws from that pool when generating the child. For a filter that references another field on the same record, it generates the fields together so the relationship holds without a second pass. The goal is one clean insert, not insert-then-fix.
Here is the part people underestimate: filter criteria can combine multiple conditions with AND/OR logic, and SproutEzee evaluates that logic exactly as Salesforce would, rather than approximating it. A filter requiring "Type equals Customer AND (Rating equals Hot OR AnnualRevenue greater than 1000000)" gets parsed condition by condition, not flattened into a single loose rule that happens to work most of the time.
Three Filter Patterns and How Each Gets Satisfied
Not all lookup filters work the same way, and treating them identically is how generators produce data that passes the easy cases and fails the hard ones. Three patterns show up repeatedly across Salesforce orgs.
- Static value filters. The filter checks a fixed value, like Account.Industry equals Technology. SproutEzee pre-builds a pool of qualifying parent records before generating children, so the lookup always has a valid target waiting.
- Field-to-field filters within the same record. The filter compares two fields on the child record itself, such as Opportunity.CloseDate falling within the Contract's active period. These get generated together, field by field, in dependency order, so the comparison holds by construction instead of by luck.
- Cross-object filters. The filter checks a field on a related parent, like requiring the Contact's Account to match the Case's Account. This is the trickiest pattern because it needs the parent chain built first, then the filtered lookup resolved against that specific chain rather than against the whole object's dataset.
Cross-object filters are where most generic tools give up and just disable validation. SproutEzee instead walks the relationship graph in the direction the filter demands, resolves the matching Account first, then picks the Contact or Asset that actually belongs to it. It is slower to compute than a random pick, but it is the only approach that produces records a real sales rep could have created.
Insert Order and Filtered Lookups
Filtered lookups add a constraint that interacts directly with insert order. If the filter requires a field on the parent that gets set after insert, by a Flow or an Apex trigger, the filter check at child-insert time might not see the value it needs yet. SproutEzee accounts for this by sequencing batches so dependent automation runs and settles before the filtered child records go in.
This matters even more with lookup filters layered on top of master-detail relationships, a combination that shows up in CPQ and asset management orgs more than people expect. The master-detail enforces that the parent exists first; the lookup filter adds a second condition on top of that existing parent. Get the order wrong and you are not looking at a filter failure, you are looking at a DML error that looks like a filter failure, which costs someone an afternoon of debugging the wrong layer.
Bulk API v2 batches load in the order submitted, so SproutEzee sequences the batch file itself: parents with their filter-qualifying fields first, then children referencing them, grouped so each batch only depends on data already committed in an earlier batch. No retries, no partial failures from a lookup filter rejecting a reference that technically exists but does not yet qualify.
Required vs Optional Filtered Lookups
A filtered lookup can be required or optional, and that distinction changes what counts as a correct test dataset. A required filtered lookup with no qualifying parent available is a hard stop; the record cannot insert validly, full stop. An optional filtered lookup just means the field stays blank when no qualifying parent exists, which is itself a scenario worth testing deliberately.
SproutEzee generates both outcomes on purpose rather than treating blank-optional as a generation failure. For optional filtered lookups, a configurable share of records gets left blank, exercising whatever logic in the org depends on that lookup being empty, things like validation rules that only fire when a reference is missing, or reports that need to surface unlinked records as a backlog. Skipping that case entirely means your test suite never confirms the empty-lookup path works at all.
For required filtered lookups, SproutEzee flags any object where the available parent pool cannot satisfy the filter criteria at the volume requested. That flag shows up before the load runs, not as a wall of Bulk API error rows after the fact. An admin configuring a 50,000-record Case load with a filter requiring an active, unassigned Asset will know in advance if the Asset pool is too thin, instead of finding out from a failed batch three hours into a load window.
Bulk API v2 Considerations for Filter-Compliant Loads
Lookup filters do not change the Bulk API v2 job mechanics, but they do change how you should think about batch composition. Because filter-qualifying parent pools can be smaller than the full object population, high-volume child loads need enough qualifying parents to avoid duplicate reuse skewing the dataset toward a handful of records.
SproutEzee tracks pool exhaustion during generation and will expand the parent dataset automatically when a filter's qualifying set is too small for the requested child volume, rather than looping the same twelve Accounts into fifty thousand Cases. That keeps the dataset's statistical shape closer to production, which matters for load testing and for any report or dashboard test that checks distribution, not just presence.
None of this requires touching the lookup filter itself. The filter stays exactly as the admin configured it in production, enforced the same way for real users and for test data. That is the point: test data should prove the filter works, not get special treatment to avoid it.
Frequently Asked Questions
What is a Salesforce lookup filter and why does it affect test data generation?
A lookup filter restricts which records show up as valid choices for a lookup field, based on criteria like status, ownership, or a match to another field on the record. Test data generators that ignore this metadata will reference records that fail the filter, causing insert errors or, if validation is bypassed, relationships that could never exist through the Salesforce UI. Reading the filter criteria during schema analysis is the only reliable way to avoid both outcomes.
Can SproutEzee generate valid test data for cross-object lookup filters?
Yes. SproutEzee resolves the parent relationship chain first, then selects the filtered lookup target based on a field from that specific chain rather than from the object population as a whole. This handles common patterns like requiring a Contact's Account to match a Case's Account before the Case-to-Contact lookup is populated.
What happens when a required filtered lookup has no qualifying parent records?
That record cannot insert validly, since Salesforce enforces the filter the same way for test data as it does for manually entered records. SproutEzee checks the available qualifying parent pool against the requested volume before the load starts and flags any shortfall, so admins can expand the parent dataset instead of discovering the problem through failed Bulk API batches.
Does a lookup filter need to be disabled to load bulk test data successfully?
No, and disabling it is a bad habit. SproutEzee generates data that satisfies the filter as configured, so the filter can stay active during test data loads exactly as it runs in production. Disabling filters to force a load through just hides problems that will surface later as real insert failures.
How does insert order interact with lookup filters and master-detail relationships?
When a lookup filter checks a field that gets set by a trigger or Flow after the parent record is inserted, the child record must wait until that automation settles before it can satisfy the filter. SproutEzee sequences Bulk API v2 batches so parent fields are committed and automation completes before dependent, filter-qualifying child records are loaded, avoiding DML errors that look like filter failures but are really ordering issues.