You need to sign in to do that
Don't have an account?
Christian Linenko
Show related content on a Case Visualforce page
I have a VF page where I'm looking to display related content on it. From the documentation I found (https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_contentdocumentlink.htm), you need to query the ContentDocumentLink object. Here's what my code looks like:
String eyeDee = Apexpages.currentPage().getParameters().get('Id');
thisCase = [SELECT Id, IsClosed, Subject FROM Case WHERE Id =: eyeDee LIMIT 1];
for(ContentDocumentLink c: [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId =: thisCase.Id])
kIds.add(c.ContentDocumentId);
content = [SELECT Id, Title, Description, Owner.Name, CreatedDate FROM ContentVersion WHERE PublishStatus = 'P' AND IsLatest = true AND ContentDocumentId IN: kIds ORDER By CreatedDate];
When I load the page however, I don't get any results.
On the standard page (https://www.dropbox.com/s/fov495yzhyelami/Screenshot%202015-01-19%2012.46.15.png?dl=0) I can see the content. On the VF page, I don't get anything.
VF Code:
<apex:pageBlock title="Related Content">
<apex:pageBlockTable value="{!Content}" var="c" rendered="{!Content.size != 0}">
<apex:column >
<apex:facet name="header">
Title
</apex:facet>
<apex:outputLink value="/customers/{!c.Id}" target="_blank">{!c.Title}</apex:outputLink>
</apex:column>
<apex:column value="{!c.Description}"/>
<apex:column value="{!c.Owner.Name}"/>
<apex:column value="{!c.CreatedDate}"/>
</apex:pageBlockTable>
<apex:outputText value="No Content Related" rendered="{!Content.size == 0}"/>
</apex:pageBlock>
Any help would be awesome.
String eyeDee = Apexpages.currentPage().getParameters().get('Id');
thisCase = [SELECT Id, IsClosed, Subject FROM Case WHERE Id =: eyeDee LIMIT 1];
for(ContentDocumentLink c: [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId =: thisCase.Id])
kIds.add(c.ContentDocumentId);
content = [SELECT Id, Title, Description, Owner.Name, CreatedDate FROM ContentVersion WHERE PublishStatus = 'P' AND IsLatest = true AND ContentDocumentId IN: kIds ORDER By CreatedDate];
When I load the page however, I don't get any results.
On the standard page (https://www.dropbox.com/s/fov495yzhyelami/Screenshot%202015-01-19%2012.46.15.png?dl=0) I can see the content. On the VF page, I don't get anything.
VF Code:
<apex:pageBlock title="Related Content">
<apex:pageBlockTable value="{!Content}" var="c" rendered="{!Content.size != 0}">
<apex:column >
<apex:facet name="header">
Title
</apex:facet>
<apex:outputLink value="/customers/{!c.Id}" target="_blank">{!c.Title}</apex:outputLink>
</apex:column>
<apex:column value="{!c.Description}"/>
<apex:column value="{!c.Owner.Name}"/>
<apex:column value="{!c.CreatedDate}"/>
</apex:pageBlockTable>
<apex:outputText value="No Content Related" rendered="{!Content.size == 0}"/>
</apex:pageBlock>
Any help would be awesome.
All Answers