You need to sign in to do that
Don't have an account?
Alexandr 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?
User license is 'customer portal login user'
Srm content user checkbox is flagged. Gets this error:
'URL is not found'
Any ideas?
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<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
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm
@Alexandr Krykun
Did you get any solution? If yes, Kindly share with me because i'm having the same issue.
Did you find any solution? Can you please share solution if you have any magic. i am facing same issue.
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 COMMUNITY (CUSTOMER PORTAL)
https://blablabla.force.com/customer
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">
<div>
<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>
<div> <p> </p></div>
</apex:page>
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());
UrlString=URL.getSalesforceBaseUrl().toExternalForm()+'/customer';
}
else{
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>();
try{
ListCon1= [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId= :posId];
ListCon0.addAll(ListCon1);
}
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);
/*try{
List<ContentDocumentLink> ListCon3= [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId =:posId];
system.debug('§§§§ ListCon3 '+ListCon3);
ListCon0.addAll(ListCon3);
}
catch(Exception e){
system.debug('§§§§ Errore a linea '+e.getLineNumber()+': '+e.getMessage());
}*/
//sopralluoghi
List<Sopralluogo__c> MySop = [Select Id, Opportunity__c FROM Sopralluogo__c WHERE Pratica__c=:posId];
system.debug('§§§§ MySop '+MySop);
for(Sopralluogo__c s:MySop){
MySopId.add(s.Id);
}
//doc sopralluoghi
if(MySopId.size()!=0){
try{
List<ContentDocumentLink> ListCon2= [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId IN :MySopId];
system.debug('§§§§ ListCon2 '+ListCon2);
ListCon0.addAll(ListCon2);
}
catch(Exception e){
system.debug('§§§§ Errore a linea '+e.getLineNumber()+': '+e.getMessage());
}
}
//Opty
try{
ListCon5 = [SELECT Id,ContentDocumentId ,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId = :PP.Opportunity__c];
system.debug('§§§§ ListCon5 '+ListCon5);
ListCon0.addAll(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 ]) {
if(docVersion.Disponibile_per_il_referente__c==true){
string ContentDown= docVersion.Id;
vehIds+= ContentDown +'/';
}
}
}
vehIdspage=vehIdspage+vehIds.removeEnd('/')+'?';
system.debug(vehIdspage);
}
}