Search Community
- Force.com Discussion Boards
- :
- Salesforce User Discussions
- :
- Best Practices Discussion
- :
- Re: Product Validation Rule
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Product Validation Rule
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-10-2009 08:33 AM - last edited on 11-10-2009 08:34 AM
Here is the background - Using PE, We have a product that includes 2 books. Most of the time, my users forget to add the 2nd book. I am trying to create a rule that will throw an error if they do not add the 2nd book. I saw in another post that you can't do this with a validation rule and so far that is proving true, but I feel like I am close.
The work I have done so far is:
AND( (Product2.ProductCode = "IMP100"), (Product2.ProductCode <>"IMP101"))
The problem with this formula is that if I add both IMP100 and IMP101, it still throws the error message.
Any help or ideas would be appreciated! Thanks!
Re: Product Validation Rule
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-10-2009 01:58 PM
I don't think you will want to do this using validation rules on line items. Instead use fields on Opportunity. This solution eats up 3 fields, a validation rule and a Workflow Rule. The 3rd field and workflow rule are only required because of a limitation in Rollup Summary fields in Salesforce. Bascially, Rollup summary fields don't read the standard Product Code field.
I can never remember whether PE has Workflow or not. If not, then this won't work unless you can work with a field like Line Description somehow.
Fields
Object: Opportunity Product
Name: Product Code (copy)
API Name: Product_Code_copy__c
Type: Text (100)
Description: This field will hold a copy of the Product Code from the related Product record. The standard Product Code field is not always visible to some Salesforce features. This field will be used when the standard field is not available. Workflow will update this field on each save.
Other Stuff: There is no need to display this on the page layout.
Object: Opportunity
Name: Total Quantity (IMP100)
API Name: Total_Quantity_IMP100__c
Type: Rollup Summary
Summarized Object: Opportunity Product
Rollup Type
UM
Field to Aggregate: Quantity
Filter: Product Code (copy) = IMP100
Object: Opportunity
Name: Total Quantity (IMP101)
API Name: Total_Quantity_IMP101__c
Type: Rollup Summary
Summarized Object: Opportunity Product
Rollup Type
UM
Field to Aggregate: Quantity
Filter: Product Code (copy) = IMP101
Validation Rule
Object: Opportunity
Rule:
AND(
IsClosed=true,
IsWon=true,
OR(
AND(Total_Quantity_IMP100__c >0,Total_Quantity_IMP101__c=0),
AND(Total_Quantity_IMP100__c =0,Total_Quantity_IMP101__c>0)
)
)
Description: This is checking for Closed opportunities that are also Won. This approach supports other flavors of the "Closed Won" stage name. Then it's looking at the 2 quantity rollup summary fields and erroring out if one of them is >0 and the other one is still 0.
Workflow Rule
Object: Opportunity Product
Criteria: 1=1
When to Run: On every credit and edit
Action: a field update rule that copies Pricebook2.Product2.ProductCode to Product Code (copy).
Activate: true

