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
LeonardLeonard 

Apex Managed Sharing Error: Invalid share row cause

I'm trying to setup a Sharing Reason and I'm having some issues.

 

Here are the steps and conditions I'm working with.

 

1. I'm working in the sandbox.

2. I have a custom object with a default sharing setting of "Private"

3. On my custom object, I created an Apex Sharing Reason. I created it by going to Setup > Create > Objects > My_Object__c and then adding a new Apex Sharing Reason

 

Now, I'm getting an "invalid share row cause" when I try the following in a Trigger

 

 

Candidate__Share managementShare = new Candidate__Share();
			managementShare.ParentId = can.Id;
			managementShare.UserOrGroupId = managementGroup.Id;
			managementShare.AccessLevel = 'edit';
			managementShare.RowCause = Schema.Candidate__Share.rowCause.Employee_Sharing_Reason;
			

 

 

What am I doing wrong? If I change the RowCause to:

 

 

Schema.Candidate__Share.RowCause.Owner

The error is gone but I'm not getting the share I want.

 

ahab1372ahab1372

I think you are missing the __c at the end of your reason:

 

From the Apex docu:

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_bulk_sharing_creating_with_apex.htm?SearchType=Stem

 

All Apex sharing reason names have the following format:

 

MyReasonName__c

 

 

 

Alex K.ax676Alex K.ax676

+1