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
DimondDimond 

Pricebook share using apex

hi all, 

after looking up and down, I am unable to find out whether pricebooks are allowed to be shared using apex. everything i've seen leads me to think that it is not currently possible. please let me know if you've discovered a way. thanks in advance!

crop1645crop1645

Partial answer - if you are exposing available pricebooks via VF pages, then

 

  • Add a custom field to Pricebook2 'allowed_profiles__c' 
  • Use your controller to show only those pricebooks where the running user's profile either matches the value in allowed_profiles__c or the pricebook2.allowed_profiles__c is null

Apex sharing is available for all custom objects plus those standard objects where there is a objSharing record in the schema. I see no such Pricebook2Sharing (or Product2Sharing for that matter) in the schema

Gretchen Gillespie 1Gretchen Gillespie 1
I'm intersted in adding a custom field to Pricebook2 to determine which users have access.  What is the formula for this field?