3

Salesforce's Spring '21 release finally offers Opportunity Product (OpportunityLineItem) lookups, which my organization has been waiting a long time for. However, we're having issues with our implementation, specifically around formula fields.

For some reason, formulas referencing certain standard OpportunityLineItem fields don't validate: ProductCode does not exist error

I've tested with a number of different fields and I've encountered the issue inconsistently. I've found the the following fields error out:

  • Opportunity_Line_Item__r.ProductCode
  • Opportunity_Line_Item__r.Name
  • Opportunity_Line_Item__r.Product2Id (and Product2.*)

But the following do not error out:

  • Opportunity_Line_Item__r.CreatedById
  • Opportunity_Line_Item__r.TotalPrice
  • Opportunity_Line_Item__r.Discount
  • Opportunity_Line_Item__r.Description

Why does the OpportunityLineItem lookup appear to be behaving differently in regards to formula field access?

2
  • can you do Opportunity_Line_Item__r.PricebookEntry.Product2.ProductCode ?
    – cropredy
    Commented Jan 25, 2021 at 19:21
  • Yes, that appears to work just fine and is a perfect workaround. Thank you! Any idea on why the standard fields aren't accessible? Commented Jan 25, 2021 at 21:39

1 Answer 1

2

As a workaround since accessing the Product2 relationship from OpportunityLineItem, QuoteItem, or OrderItem has often given developers trouble is to use the PricebookEntry relationship:

  • Opportunity_Line_Item__r.PricebookEntry.Product2.ProductCode
  • Opportunity_Line_Item__r.PricebookEntry.Product2ID

etc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .