0

I need to write a validation rule on opportunity that pricebook 'A' & 'B' can be used only for Opportunity record type '1'. If any other record type is selected then other than these price books can be selected but not 'A' & 'B'. I have written a rule which works only for that case but if tested for some other it saves the record.

((RecordTypeId != '1') && ((Pricebook2Id = 'A') || (Pricebook2Id = 'B')))

Can someone please help?

1 Answer 1

1

You want your validation rule to return FALSE when the user should be allowed to save. So, assuming you want Record Type '1' to only allow price books A and B, then you need to make sure that it returns FALSE when A or B is selected, and TRUE otherwise. Based on that information, it looks like you want something like the following:

IF($RecordType.Name='1',
    Pricebook2.Name<>'A' && Pricebook2.Name<>'B',
    Pricebook2.Name='A' || Pricebook2.Name='B')

You must log in to answer this question.

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