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
v jv j 

Urgent Help required to Use USERMEMBERSHIPSHARINGRULE in apex ?

Hi I am trying to create Auto User Sharing Rule , Which will share a public group with public group the above object fits for the requirement .But not able to use it since on using getting Compile Error.
Code in Apex class :
UserMembershipSharingRule oUserMembershipSharingRule =new UserMembershipSharingRule();
UserMembershipSharingRule.GroupId= spaceid; //spaceid is the public groupid
UserMembershipSharingRule.UserOrGroupId= spaceid;
UserMembershipSharingRule.UserAccessLevel = 'Read';

Error: Compile Error: No access to entity: UserMembershipSharingRule at line 1 column 8 "
 
PratikPratik (Salesforce Developers) 
Hi Vj,

UserMembershipSharingRule' is Metadata not an object however performing operations on it is possible.

You can refer to this:
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008wORIAY

Thanks,
Pratik