Skip to content

Check whether open pipeline includes a previously purchased product

Create a Check that compares Product IDs on open Opportunity Products with Product IDs on closed-won Opportunity Products. It passes when the two visible lists overlap.

The requirement compares two sets of related records. Compare two queries can collect each Product list and test for overlap without Apex.

  • Confirm that closed-won Opportunity Products are your approved purchase-history source. Many orgs use Assets, Orders, or another object instead; adapt the comparison query when they do.
  • Confirm intended users can read Opportunities, Opportunity Products, and Product IDs.
  • Decide that no rows should skip. In this example, missing open pipeline or purchase history does not create a warning.
  • Save new configuration inactive and validate it before activation.

Use Account Record Alignment, or create an Account Check Set that runs on click and remains inactive until validation succeeds.

Open Setup → Custom Metadata Types → Record Health Check → Manage Records, select New, and enter:

Salesforce fieldValue
LabelOpen Pipeline Uses Purchased Product
Record Health Check NameOpen_Pipeline_Uses_Purchased_Product
Check SetAccount Record Alignment
Check TitleOpen pipeline includes a previously purchased product
Evaluation TypeCompare two queries
Source QuerySELECT Product2Id FROM OpportunityLineItem WHERE Opportunity.AccountId = {!record.Id} AND Opportunity.IsClosed = false
Source Query FieldProduct2Id
Comparison QuerySELECT Product2Id FROM OpportunityLineItem WHERE Opportunity.AccountId = {!record.Id} AND Opportunity.IsWon = true
Comparison Query FieldProduct2Id
How To Read Query ResultsCompare as lists
Comparison OperatorLists overlap
If Query Finds No RecordsSkip
Failure SeverityInfo
Message When FailedOn {!record.Name fallback="this Account"}, open pipeline products do not overlap products on closed-won Opportunities.
Fix MessageReview product selection and correct it only when it does not match the intended sale.
Action LabelReview opportunities
Action URL/lightning/r/Account/{!record.Id}/related/Opportunities/view
Evaluation Order10
ActiveUnchecked until validation succeeds
  1. Run the configuration-validation Flow.
  2. Correct every error and confirm the purchase-history model.
  3. Activate the Check and Check Set only after validation succeeds.
  4. Test from the Account page with Record Health Check Card User.
Open-pipeline Product IDsClosed-won Product IDsExpected result
NoneAnySkipped
AnyNoneSkipped
ABInfo
A, BB, CPass

Repeat with intended sharing. Hidden Opportunity Products cannot contribute to either list.

The card compares the two visible query results using the configured list or numeric operator.

Result detailMeaning
PASSThe source and comparison results satisfy the configured operator.
FAILThe results do not satisfy the operator, and the card shows the configured guidance.
SKIPPEDThe Check does not apply or a configured prerequisite did not pass.
FoundThe normalized result returned by the source query.
ExpectedThe normalized result returned by the comparison query.
What you seeCheck this first
Expected purchase history is missingConfirm your org records purchases on closed-won Opportunity Products
Unrelated products passConfirm Lists overlap means any shared Product ID; use another operator if policy requires full coverage
The Check skipsConfirm both queries return at least one visible row
Unable to CheckConfirm relationship paths, object access, field access, and sharing