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
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Validation on Manual Sharing of Private Record -- Possible??

Hi All,

I have a requirement here , can anyone help me ??

Custom Object : Name - "Test Object"
Sharing Setting : Private
Manual Sharing : Enabled (By displaying custom button on the Page Layout)

Users are allowed to share the records with "Role A and its subordinates" as and when required , but should be prohibited to share the records with "Role B and its subordinates". 

Can we add some sort of capability that prohibits user from giving access to anyone apart from "Role A and its subordinates" ?
Raj VakatiRaj Vakati
That you cannt do it with valition rule.. but you can do it with the trigger .. 

Write an trigger on object and get the sharing casue and see 

Refer this links

https://salesforce.stackexchange.com/questions/131160/dynamically-assigning-sharing-reason-to-object
https://www.forcetalks.com/salesforce-topic/can-we-define-apex-sharing-reason-for-standard-object/
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm