+ Start a Discussion
Alexandr KrykunAlexandr Krykun 

Unable to download Content version in community

User that logged in customer community is not able to download content version files through this link https://<community-domain>/<community instance>/sfc/servlet.shepherd/version/download/<content document Id>
User license is 'customer portal login user'
Srm content user checkbox is flagged. Gets this error: 
'URL is not found'
Any ideas?
Vandana Jaiswal 7Vandana Jaiswal 7
Hi @alexandr Did you find any solution for this? Thank you

I believe the Id is wrong in that link. We are using the following and it is working:

where downloadId is actually the ContentVersion.Id
Vandana Jaiswal 7Vandana Jaiswal 7

<apex:outputLink value="/sfc/servlet.shepherd/version/download/068m0000000Dxes">Test (MS PowerPoint)</apex:outputlink>

Here is the link I am using but doesn't seems to work

Vandana, that link looks perfect. Are you creating a Content Document Link prior to exposing the link? That might be the step you are missing in the process. Let me know if this helps.


@Alexandr Krykun

Did you get any solution? If yes, Kindly share with me because i'm having the same issue. 


kishore reddy 21kishore reddy 21
Did you find any solution? Can you please share  solution if you have any magic. i am facing same issue.
Riccardo Torchio 7Riccardo Torchio 7
Maybe I can help you:
in customer commmunity to download the files through a visualforce page you need to add the domain of the community itself prior the servlet link. Here is a dynamic solution as an example:


MY PROFILES (just the names)
Customer Community - Amministratore di Condominio
Customer Community - Collaboratore
Customer Community - Collaboratore di Azienda
System Administrator (that's me)

CUSTOM OBJECT (as a standard controller)
Pratica__c (which has a lookup to the opportunity, btw)

VISUALFORCE PAGE (note: "vehIdspage" is a precious variable)
<apex:page StandardController="Pratica__c" extensions="DocPerReferente_Controller" lightningStylesheets="true">
        <CENTER><apex:outputLink value="{!URLFOR(vehIdspage)}" target="_document" style="align:center">Clicca qui per scaricare tutti i documenti disponibili al Referente dell'Opportunità</apex:outputLink></CENTER>
    <div>   <p>&nbsp;</p></div>


CONTROLLER APEX (EXTENSIONS) //it's full of system debug, so you can notice the most critical points of fracture
public with sharing  class DocPerReferente_Controller {
    public String vehIdspage{get;set;}
    public Id posId       {get;set;}
    public DocPerReferente_Controller(ApexPages.StandardController controller) {
        posId = controller.getRecord().Id;
        system.debug('§§§§ posId '+posId); 
        system.debug('§§§ URL.getSalesforceBaseUrl() '+URL.getSalesforceBaseUrl());
        system.debug('§§§ URL.getSalesforceBaseUrl().toExternalForm() '+URL.getSalesforceBaseUrl().toExternalForm());
        String AmmProfId=[SELECT Id, Name FROM Profile WHERE Name='Customer Community - Amministratore di Condominio' LIMIT 1].Id;
        String CollProfId=[SELECT Id, Name FROM Profile WHERE Name='Customer Community - Collaboratore' LIMIT 1].Id;
        String CollAziendaProfId=[SELECT Id, Name FROM Profile WHERE Name='Customer Community - Collaboratore di Azienda' LIMIT 1].Id;
        String UrlString='';
        system.debug('§§§§ UserInfo.getProfileId() '+UserInfo.getProfileId()); 
        system.debug('§§§§ CollProfId '+CollProfId); 

        if(UserInfo.getProfileId()==AmmProfId || UserInfo.getProfileId()==CollProfId || UserInfo.getProfileId()==CollAziendaProfId){
            system.debug('§§§ sono dentro UserInfo.getProfileId() '+UserInfo.getProfileId());
            system.debug('§§§ sono fuori');
        vehIdspage=UrlString+'/sfc/servlet.shepherd/version/download/' ;
        system.debug('§§§ vehIdspage '+vehIdspage);
        String vehIds='';
        List<ContentDocumentLink> ListCon0 = new List<ContentDocumentLink>();
        List<ContentDocumentLink> ListCon1 = new List<ContentDocumentLink>();
            ListCon1= [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId= :posId];
        catch(Exception e){
            system.debug('§§§§ Errore a linea '+e.getLineNumber()+': '+e.getMessage()); 
        system.debug('§§§§ ListCon1 '+ListCon1); 
        List<ContentDocumentLink> ListCon5 = new List<ContentDocumentLink>();
        List<ContentDocumentLink> ListCon6 = new List<ContentDocumentLink>();
        List<SAL__c> SALList = new List<SAL__c>();       
        set<Id> MySopId= new set<Id>();
        set<Id> MyPratId= new set<Id>();
        set<Id> MyAttId= new set<Id>();
        set<Id> MySALId= new set<Id>();
        Pratica__c PP = [SELECT Id, Opportunity__c FROM PRatica__c WHERE Id=:posId];
        system.debug('§§§§ PP '+PP); 
            List<ContentDocumentLink> ListCon3= [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId =:posId];
            system.debug('§§§§ ListCon3 '+ListCon3); 
        catch(Exception e){
            system.debug('§§§§ Errore a linea '+e.getLineNumber()+': '+e.getMessage()); 
        List<Sopralluogo__c> MySop = [Select Id, Opportunity__c FROM Sopralluogo__c WHERE Pratica__c=:posId];
        system.debug('§§§§ MySop '+MySop); 
        for(Sopralluogo__c s:MySop){
        //doc sopralluoghi
                List<ContentDocumentLink> ListCon2= [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId IN :MySopId];
                system.debug('§§§§ ListCon2 '+ListCon2);
            catch(Exception e){
                system.debug('§§§§ Errore a linea '+e.getLineNumber()+': '+e.getMessage()); 
            ListCon5 = [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId = :PP.Opportunity__c];
            system.debug('§§§§ ListCon5 '+ListCon5);
        catch(Exception e){
            system.debug('§§§§ Errore a linea '+e.getLineNumber()+': '+e.getMessage()); 
        system.debug('§§§ ListCon0 '+ListCon0);
        system.debug('§§§ ListCon0.size() '+ListCon0.size());
        for(ContentDocumentLink conDoc: ListCon0){
            for (ContentVersion docVersion : [Select Id, Disponibile_per_il_referente__c, VersionData from ContentVersion where ContentDocumentId =:conDoc.ContentDocumentId ]) {
                    string ContentDown= docVersion.Id;
                    vehIds+= ContentDown +'/';
Riccardo Torchio 7Riccardo Torchio 7
PS the checkbox in the ContentVersion for-loop is actually this one:

The checkbox "Disponibile_per_il_referente__c" is in the Uploaded file details' page,