Disable downloads for certain users based on the name of the file uploaded to Salesforce. We can use the following example code inside of a Apex class. This code essentially prevents files whose file name starts off with Kaipu- from being downloaded by anyone whose user role’s developer name is not Kaipu_Sales. Modify this code to suit your own purpose. Based on Role: public class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory { public Sfc.ContentDownloadHandler getContentDownloadHandler(List<ID> ids, Sfc.ContentDownloadContext context) { // See if the user has the Kaipu Sales role (based on developer name field). Boolean isSecretUser = [ SELECT Id FROM UserRole WHERE ID = :UserInfo.getUserRoleId() AND DeveloperName = ' Kaip...
Learning Salesforce in an easy way
Learn and share...