Recipes by Category

App Distribution (2) Bundle logic, interface and services for distribution. App Logic (37) The Apex programming language, workflow and formulas for logic. Collaboration (5) The Salesforce Chatter collaboration platform. Database (29) Data persistence, reporting and analytics. Integration (33) Web Service APIs and toolkits for integration. Security (9) Platform, application and data security. Tools (4) Force.com tooling User Interface (36) Visualforce MVC and metadata-drive user interfaces. Web Sites (12) Public web sites and apps with optional user registration and login.
Beta Feedback
Cookbook Home » Displaying Salesforce CRM Content Documents in a Visualforce Page

Displaying Salesforce CRM Content Documents in a Visualforce Page

Post by Developer Force  (2010-07-16)

Status: Certified
Level: novice

Problem

You want to customize how a Salesforce CRM Content document's detail page looks to end users to include your company's branding.

Solution

Create a Visualforce page that displays the Salesforce CRM Content document's details in a customized way.

Create a custom Visualforce controller that retrieves all the documents available to the current user. Controllers are created as Apex classes.

In this class, the SOQL query selects the latest version of all content, as well as the title, description, file type, owner name, and version number.

public class ContentVersionAlt {

    public List<ContentVersion> getContentVersions() {
        return [select id, Title, Description, FileType,
        Owner.Name, VersionNumber from ContentVersion
        Where IsLatest = true];
    }

}
Create a Visualforce page that displays all the files selected in the controller in a table:
<apex:page controller="ContentVersionAlt">
       

Current User's Latest Version of All Accessible Files

<table border="1"> <thead> <th>Title</th> <th>Description</th> <th>FileType</th> <th>Author</th> <th>Revision</th> </thead> <tbody> <apex:repeat var="cv" value="{!contentVersions}"> <a href="/{!cv.id}">{!cv.title}</a> {!cv.description} {!cv.FileType} {!cv.Owner.Name} {!cv.VersionNumber} </apex:repeat> </tbody> </apex:page>

Share

Recipe Activity - Please Log in to write a comment

Great article.  Would it be difficult to do this with Salesforce 'Files' instead of Content?

by Wei Chiang  (2013-07-09)

Great article.  Would it be difficult to do this with Salesforce 'Files' instead of Content?

by Wei Chiang  (2013-07-09)

Great article.  Would it be difficult to do this with Salesforce 'Files' instead of Content?

by Wei Chiang  (2013-07-09)

Hi,

We have created a simlar visual force page and controller,
Also added the page to the content type.

But the page is not displayed while loading the content detail page.
Kindly sugges.

Regards,
Asha Namboodiri

by Asha Narayanan  (2013-03-17)

good!

by VENKATA NARASIMHARAO  (2011-07-29)

X

Vote to Verify a Recipe

Verifying a recipe is a way to give feedback to others and broaden your own understanding of the capabilities on Force.com. When you verify a recipe, please make sure the code runs, and the functionality solves the articulated problem as expected.

Please make sure:
  • All the necessary pieces are mentioned
  • You have tested the recipe in practice
  • Have sent any suggestions for improvements to the author

Please Log in to verify a recipe

You have voted to verify this recipe.