4

According to the documentation on OpportunityShare about RowCause:

You can create a value for this field in API versions 32.0 and later with the correct organization-wide sharing settings.

However, according to the fore.com developer guide (p. 187 as of the time of this post)

Apex Sharing reasons and apex managed sharing recalculation are only available for custom objects.

I can't find a way to edit it via the UI and tried retrieving the picklist value from workbench but I got the error "Entity of type 'CustomObject' named 'OpportunityShare' cannot be found" which as I understand it is generally shown when an object is not modifiable...

Is it possible to add a value to this field, or is this a Salesforce documentation error?

1 Answer 1

3

Its just tricky wording..

Create - "When creating a record" - not create your own value

When creating an OpportunityShare or modifying an OpportunityShare where the RowCause is not set you can set the value to:

Valid values include:

  • Owner—User is the owner of the opportunity.
  • Manual—User or group has access because a user with “All” access manually shared the opportunity with the user or group.
  • Rule—User or group has access via an opportunity sharing rule.
  • ImplicitChild—User or group has access to the opportunity on the account associated with this opportunity.
  • Sales Team—User has access to the opportunity because the user is on the opportunity sales team for the opportunity. The OpportunityTeamMember object sets the access level. See OpportunityTeamMember for more information.

However you CANNOT create your own custom sharing reason values to set the row cause to

Hence the Apex Sharing reasons only being available for custom objects.

Also, OpportunityShare is only available to query via the UI if the OWD for the Opportunity are NOT set to public read / write. If the OWD is set to public read / write then you will get a query error

enter image description here

8
  • Ah I see what you mean! Quite trick! Is there any way you know to differentiate manual shared records inserted by an apex rule vs by a user? I'm trying to create a re-calculate batch and need to be able to differentiate. Sep 13, 2016 at 20:06
  • @SamKamensky - In the doc create means to populate the value of the field not create a value for the picklist. Different from Edit, meaning you can modify the value. So the field value is creatable not editable
    – Eric
    Sep 13, 2016 at 20:08
  • @SamKamensky - Unfortunately not with some trickery of your own. Ran into this many times before. You can use your own tables, fields, etc to manage the sharing. In my case we just removed all manual share daily and recalculated the manual share we want via code. Since we could not differentiate between manual (user created) and manual (code created) the daily job was the most convenient route for us
    – Eric
    Sep 13, 2016 at 20:11
  • ahhh okay thank you! Sep 13, 2016 at 20:31
  • 2
    I ended up creating an object 'ApexStandardObjectShare__c' with two fields 'ObjectedShared' and 'ShareRecordId.' I only insert these objects after I share somewhere in my code. When the user manually shared, this record isn't created. Now when I do the batch to recalculate records I can look for shares that are in the Ids of the records I created, delete them all, and recalculate everything! Sep 14, 2016 at 17:07

You must log in to answer this question.

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