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
Michaela GrundmanMichaela Grundman 

Need help with preventing certain quote line items being chosen.

There are two products we have in our system (Customer Supplied Tires) and (Michelin Tire Upgrade).  They are different products but should not be chosen on the same quote. I need a trigger (or something) that will allow our users to pick 1 or the other, but not both.  If someone can help, please let me know and I will be happy to provide more detailed information.

Thank you - 
MGrundman
RamuRamu (Salesforce Developers) 
For this I guess you would need to go with triggers as the standard validation rule cannot be used for this kind of complex requirements.

In the triggers, you would need to create two map collection variables with the definition as Map<id,string>. One map to populate all the opportunity id and true or false based on the associated quote records that has 'Customer Supplied Tires.
The second map to populate all the opportunity id's and True or false based on the associated quote records that has Michelin Tire Upgrade.

Then you can loop through new quote collection and if the quote is 'Michelin Tire Upgrade, see if that Opportunity already has Customer Supplied Tire and vice versa.

Hope this helps !!
Mikola SenykMikola Senyk
Hi!

You can add custom text field on Product object e.g. Exclusive_Code__c. Put the same value in this field for these two products.
Create trigger for Opportunity Products on insert and update. In this trigger we are interesting on OpportunityLineItems with not empty Product2.Exclusive_Code__c. We have to query on the existing Opportunity Products and match Exclusive_Code__c. If values are the same we will add error to the record.