I have multiple (PB) price books, A, B, C, D. I want to give full access to PB C & D to all Sales Reps for all opportunities, and only give access to PB A & D if the Manager selected either of those options for a specific opportunity only. If I remove access to all PB and then open it for C & D with a sharing rule, seems to be fine, and the Sales Reps would only be able to see those two. However once PB A or D would be shared for use on a single opportunity, wouldn't it be available for use on all?
-
Validation rule on Opportunity ? Otherwise you could also automate PB assignment if you don't want them to choose– brovasiAug 28, 2016 at 22:51
-
Apex managed sharing– cropredyAug 28, 2016 at 23:56
1 Answer
You can use a validation rule to prevent using the price book. It'll still show up in the list, they just won't be able to select it.
Example:
NOT($Permission.Manager) &&
(ISNEW() || PRIORVALUE(Pricebook2Id) <> Pricebook2Id) &&
(Pricebook2.Name = 'A' || Pricebook2.Name = 'D')
This rule says: "If the current user doesn't have Manager permissions, and this is a new opportunity, or the pricebook is being changed, and the price book name is A or D, display an error."
You can also implement this same logic by way of trigger if your code was overly complex. For most cases, I'd suspect a validation rule should suffice.