You need to sign in to do that
Don't have an account?
Nathan Marchant
How to write SOQL query with two objects
Hi,
I need to write this as one single query as i need to display this information inside one table on visualforce.
Basically I need to
find name of document and ContentDocumentId from ContentDocumentLink where LinkedEntityId equals an accountid for example "0016E00000ZdEEdQAN"
now in the same query i wish to find DistributionPublicUrl from ContentDistribution where ContentDocumentId equals ContentDocumentId we found this value in the first part of the query.
I have managed to get these two querys working seperatly in my apex my using a variable to save the ContentDocumentId
here are my seperate versions:
CDRecords =[SELECT ContentDocumentId, ContentDocument.title FROM ContentDocumentLink WHERE LinkedEntityId = '0016E00000ZdEEdQAN' ALL ROWS];
CDId = CDRecords[i].ContentDocumentId;
[SELECT DistributionPublicUrl FROM ContentDistribution WHERE ContentDocumentId =:CDId]
Here is my attempt at doing one query. Im not really sure how to do this. if anyone can help me out that would be great!
SELECT ContentDocument.title
(SELECT DistributionPublicUrl FROM ContentDistribution WHERE ContentDocumentId = ContentDocumentLink.ContentDocumentId) FROM ContentDocumentLink WHERE LinkedEntityId = '0016E00000ZdEEdQAN'
I need to write this as one single query as i need to display this information inside one table on visualforce.
Basically I need to
find name of document and ContentDocumentId from ContentDocumentLink where LinkedEntityId equals an accountid for example "0016E00000ZdEEdQAN"
now in the same query i wish to find DistributionPublicUrl from ContentDistribution where ContentDocumentId equals ContentDocumentId we found this value in the first part of the query.
I have managed to get these two querys working seperatly in my apex my using a variable to save the ContentDocumentId
here are my seperate versions:
CDRecords =[SELECT ContentDocumentId, ContentDocument.title FROM ContentDocumentLink WHERE LinkedEntityId = '0016E00000ZdEEdQAN' ALL ROWS];
CDId = CDRecords[i].ContentDocumentId;
[SELECT DistributionPublicUrl FROM ContentDistribution WHERE ContentDocumentId =:CDId]
Here is my attempt at doing one query. Im not really sure how to do this. if anyone can help me out that would be great!
SELECT ContentDocument.title
(SELECT DistributionPublicUrl FROM ContentDistribution WHERE ContentDocumentId = ContentDocumentLink.ContentDocumentId) FROM ContentDocumentLink WHERE LinkedEntityId = '0016E00000ZdEEdQAN'
I don't see any direct relationship with contentdocumentlink to ContentDistribution .
Also Salesforce does not support relationship for contentDocument or ContentVersion for SOQL.
So your separate version is the only way to get contentdistribution.