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
certi_vimalcerti_vimal 

Users should not be able to manual share their records with Roles/Roles and Subordinates

Customer wants that when a user goes to grant access to another user via Manual Sharing, they should not have option to share with Roles and Roles-Subordinates. The users should only be able to share with another users. 


I know from the standard out-of-box Salesforce Page for Sharing, we cannot remove these options from the left-hand side palette.


However, can we have some customized APEX trigger or some sort of validation which will not allow users to share their records with Roles/Roles and Subordinates?


Please advise.



Thanks,


Vimal

sfdcfoxsfdcfox

You can't run triggers on any Share objects, so that option is out. The best that you could do in that aspect is to create a Batch Apex Class that is scheduled to run periodically to forcibly remove those shares after the fact (for example, every night). The alternative would be to use a Visualforce page instead of the standard Share page; this would allow you to control the options available to a user (although a savvy user could work around that anyways...). I belive your only true option is to explain that sharing is what it is, and to submit a feature request on ideas.salesforce.com. Besides, if you couldn't share with a role, what would stop the user from just sharing with every user they want to manually; all you are doing is slowing down the inevitable.