function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rob.RosenRob.Rosen 

Validation Rule Requiring Quote Line Item Based on Another

Hi there,

 

I'm trying to create a validation rule for quote line items where the constraints is that if a particular item is present the list, one of several others must also be present.  I've tried a bunch of things and am completely stymied by this so far.  Anyone have an idea for me?


Thanks,

Rob

lrw7572lrw7572

Are you refering to adding more than one line item at a time (e.g. click new line item and force user to select more than one product)? I don't think there is any way to check between records that are being inserted through a standard salesforce validation rule, but you could write a 'before insert' trigger that checks that the required items are in the list before it inserts them and throws an error if not.

Rob.RosenRob.Rosen

Thanks for the response.  Let me try to clarify:  I'm having my users add products to opportunities, and these then get carried over as the quote line items.  I want to check if they chose a certain hardware product (Product H) and if they did, they MUST choose a software license to accompany it from 3 possibilities (Product A, B, or C).  So I want to check if H is there, and if yes, confirm that one of A/B/C is also there before they can move forward.

 

I don't care if this is forced at the time of  initial product selection or if it's forced later.  I was hoping to use a validation rule at the time they try to create the quote from the opportunity, but I'm open to other ways.  Not much good with triggers so I was really hoping to use a validation rule.

 

I considered creating a custom field (rollup summary) to count the instances of product H among the opportunity products or quote line items, and another one to count the instances of A/B/C.  Then I could look at those two fields to check if things are OK.  Unfortunately, I cannot get at the product name in these fields and therefore can't make this approach work either.

 

Rob

Jeff MayJeff May

Validation Rules only work on a single record at a time, so you will have to go the route of rollup fields.  You should be able to create a custom formula field on the line item that gets you a text value of the related product name.  Then, you can do a rollup based on the value in that custom text field.

 

For example:  a custom formula field with a formula like Product2__r.ProductName will contrain the product name,  Then, you can roll up based on the value in that field.

Rob R.ax1647Rob R.ax1647

Thanks -- that's exactly what I tried to do, but I can't create a rollup at the Quote object level that uses custom fields from the Quote Line Items in the filter.  Apparently that's not allowed.

AYStribsAYStribs
Hey Rob, 

Did you ever find a way around this? I'm having a similar issue.