Line Item Schedule Lookup Formulas

In Salesforce, the Opportunity Line Item Schedule Object represents information about the quantity, revenue distribution, and delivery dates for a particular Opportunity Line Item. It’s part of Sales Cloud. On the Salesforce Ohana Slack, which can be be joined here, someone asked how they could use a flow to delete these opportunity line item schedule records when an opportunity reaches a certain status. My first thought was that should be easy… Create an after-save flow on the Opportunity object with the desired start conditions and then use a “Delete Records” element on “Opportunity Line Item Schedule” using the criteria setting with a criteria of “Opportunity Id = {! $Record.Id}”. There is no Opportunity Id on the Line Item Schedule Object though.

To fix that, a text formula field would easily do. When I went to create the formula, the “Opportunity Product” lookup wasn’t in the field lookup modal which was very strange to me! That implies it’s unavailable.

Since I’m not one to give up so easily, I wondered if one could just type the reference in manually… so I typed in

OpportunityLineItem.OpportunityId

hit the “Check Syntax” and….

Success! Others were very happy to learn that was possible and I was happy to learn something new too.

Product Id Lookup Formula

One can also reference the Product Id if needed but one has to go through the Pricebook Entry relationship to get it instead of the Opportunity Product’s “Product Id”, which Salesforce won’t let one access. This is good:

OpportunityLineItem.PriceBookEntry.Product2Id

Not Good:

OpportunityLineItem.Product2Id

One would think that should work since it’s listed as a field in the Opportunity Line Item documentation. Salesforce, if you’re reading this, why is that?

Lessons Learned

  • Even though the field or relationship isn’t listed in the formula field modal, does not mean it isn’t accessible! Try writing the formula manually and see what happens.
  • To create formula fields on the “Opportunity Line Item Schedule” object, the “Enable customization of product schedules (Lightning Experience only)” setting must be enabled on the “Product Schedule Settings” page in Setup.