+ Start a Discussion
joel.jiangjoel.jiang 

Download file in custom site (Community) with license "Custom Community Login"

Hi, 

I met a problem, now I create a custom profile with license "Custom Community Login", and also one pubilc site (Community), then I hope that I could download file (a link) with this profile, but it always failed. Could it work with this license ?

Thanks !
Tarun Khandelwal 11Tarun Khandelwal 11
Hello,

I am also facing the same problem. We are using Custom Community licenses and want use Salesforce File or Salesforce CRM Content. But unable to do so.
Is it allowed to access these modules from Customer Community?
Brian Clark 17Brian Clark 17
Community users can only access files that were uploaded INTO that community. (ie when an internal user with a full SFDC license uploads a file, the community users can't see it, eventhough the community users have access to view the record.)

HOWEVER!!!!! After a combined effort of 3 SFDC certified dev's and a lot of R&D we found the easiest and simplest solution was a SINGLE line of code in an apex trigger: UpdateContentDocumentLinkVisibilityOnInsert on ContentDocumentLink (before insert) { for(ContentDocumentLink l:Trigger.new)l.Visibility='AllUsers'; }

You'll still want to write the Test Classes; otherwise contact us we have everything ready to go. Brian<at>acuitymg.com 53O-454-5683
Piotr GajekPiotr Gajek
You can check my post (http://salesforceprofs.com/how-to-download-files-in-salesforce-community/), where I explain how you can create the download link in APEX. 
 
String fileDownloadUrl = URL.getSalesforceBaseUrl().toExternalForm()  + '/sfc/servlet.shepherd/document/download/' + contentDocument.Id + '?operationContext=S1';

You need also check, that you file is shared with community user. If not, you need share by APEX code, because you cannot share documents manually with community users.

Use below apex code to share your file with community user before download.

ContentDocumentLink contentDocumentLink = new ContentDocumentLink(
                                              LinkedEntityId = recordIdWithWhichYouWantToShareFile,
                                              ContentDocumentId = contentDocumentIdWhichYouWantShare,
                                              shareType = 'V',
                                              Visibility = 'AllUsers'
                                          );

insert contentDocumentLink;

Feel free to ask! 

Regards,
Piotr
Arghyadeep SurArghyadeep Sur
Greetings Joel ,
 Have been facing the same problem but was able to acheive this using the steps mentioned below.
 
Open Experience Page Administration->Pages->Advanced Customizations->Go to Force.com->Custom URLs
User-added image
To create public download use the following format - 
domain Name + path + /sfc/servlet.shepherd/document/download/ContentDocumentId?operationContext=S1
Replace the ContentDocumentId with the respective content document Id .
Use this link wherever you want the user to download any file.
Also , please ensure that 
shareType = 'V', Visibility = 'AllUsers' on ContentDocumentLink while uploading the document/file.
Please mark this as the best answer if this solves your problem.


Thanks,
Arghyadeep