You need to sign in to do that
Don't have an account?

User Pricebook Permissions
Hey All,
I'm creating a custom visualforce page(s) which allows users to select a subset of pricebookentries and insert them into an existing quote. Before I show the available products, I need them to select a pricebook. I only want to show each user the pricebooks that they are allowed access to in a select list. Is there a way for me to get a List of all of the pricebooks that a user is allowed access to? Is there an object that I can query which holds this data? I read somewhere on the boards to query PriceBookShare, but that is an invalid ObjectId
Thanks for any help in advance!
Josh
Use a query, as follows:
You could make other queries based on other conditions, but this should be a good starting point.
All Answers
Not all objects are supported in Apex Code natively (yet). Try using the "with sharing" keyword on your controller, which should honor the pricebook sharing model.
I'm using with sharing at the moment. The problem is that I'm probably not using the correct method for selecting a pricebook... I created a custom drop down with a list of all of the pricebooks, so they all show up for everyone.
This is what I have for the drop down list right now. As you can see, there is no way for the system to limit selections based on what the user has access to.
Is there already a method setup to select pricebooks that would conform to the "with sharing" call?
Thanks
Use a query, as follows:
You could make other queries based on other conditions, but this should be a good starting point.
Genius. This works perfectly since the page will only return Ids which the user has access to. Thank you so much!