I am trying to create a validation rule that will require a date field (renewal date) be populated before an Opportunity can be closed as won if a product from a particular family (Software) is included in the Opportunity. Basically forcing a sales agent to select a renewal date if they are including a renewable SaaS product in the Opportunity (as opposed to say hardware or a one time service fee).

What I have currently is failing, " Error: Field Product2 does not exist. Check spelling." Slight variations produce the same error (for example Product2_Family__ etc etc). Is it not possible to include Product family in a validation rule for an Oppty? Or is the issue the use of "TEXT". Picklist wouldn't work here - so what might it be?

AND( IsClosed = TRUE, IsWon = TRUE, TEXT(Product2.Family, "software"), ISBLANK(Renewal_Date__c))

1 Answer 1



You should be able to accomplish this will a workflow and a rollup summary field (with the assumption that you won't be changing Product Family on existing Products).

If you create a new Text field on your OpportunityLineItem to hold the Family value, you can populate it in a Workflow Field Update. You can make this hidden from the user.

Workflow Rule

Workflow Field Update

Once you have that populating for your new Opportunity Products, you can use a rollup field to count the number of Opportunity Products that meet the criteria you define (Family = Software).

Rollup Field

Then you can base your validation rule on this field being 0 or 1+.

For existing OpportunityLineItems, you can either manually populate the field via a DataLoad or Anonymous Apex.


You won't be able to create a validation rule on an Opportunity that references values of an Opportunity Product because it can't tell which Product to validate - You can only reference parent records in a validation rule (so for Opportunity, you could reference Account).

You'll likely need to write a trigger on the OpportunityLineItem that check the Products Family and updates a checkbox (or some field) on the corresponding Opportunity that there is a product that belongs to that family. If you go down this path, you'll want to re-verify that value every time an Opportunity Product is added or deleted (you may have delete the last Product of Family X, or you may have deleted one of two, etc).

Once you have that checkbox field populated on the Opportunity via a trigger, you'd be free to include it in a validation rule.

  • I was hoping that wasn't the case, but thank you Michael - that is what I needed to know.
    – Greg P
    Jan 16, 2014 at 18:47
  • Actually, I think I found a way without code. Give me a minute to update the answer. Jan 16, 2014 at 18:51
  • @GregP Take a look at the update I made. I think that is the answer you were looking for :) Jan 16, 2014 at 18:59

You must log in to answer this question.

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