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
Big_BBig_B 

WFR and Validation Rules with Opportunity Products and Opportunities

I am trying to validate that all opportunity products added to an opportunity are of the same category (custom field) and provide a user with an error if the category of subsequent opportunity products don't match the first one.

 

Here is my logic:

  1. Add the first opp product and the opp product WFR with field update takes the OppProductCategory value and plugs it into the OppCategory on the opportunity.
  2. Second opp product is added and the Validation rule compares the OppProductCategory value on the opp product with the new OppCategory on the opportunity.  If it matches, great.  If it doesn't then throw an error.

Everything works great unless 2 or more opp products with different category values are added during the initial 'Add Products' session.  It's almost like the WFR that should fire after each opp product is added isn't firing until after both records are added which renders the Validation rule for the 2nd opp product record useless.

 

Am I missing something with the timing or sequence of events?

 

Thanks!

Bryan

 

Grazitti TeamGrazitti Team
This is possible if you write a trigger to setup the oppcategory on Opportunity since, with workflow you are not sure whetehr there woudl be a bulk insertion of line items or not.
So best is to go with the trigger approach .


let us know if you have any question .
please don't Forget to Mark this as your best answer if it works fine for you

Regards,
Grazitti Team
Web: www.grazitti.com