Skip to content

Content Document Table ​

A generic table to show shared documents from a Salesforce Files library.

Type: Component

Available in: App Page · Home Page · Record Page · Flow Screen

Content Document Table

Read on Medium ​

How to build a Content Document Datatable with Apex & LWC

How to build a Content Document Datatable with Apex & LWC

Attributes ​

NameTypeDefaultDescription
card-iconstring'standard:file'If show card option is active, the card icon is displayed in the header before the card title. It should contain the SLDS name of the icon. Specify the name in the format 'standard:file' where 'standard' is the category and 'case' the icon to be displayed.
card-titlestring'Document Table'If show card option is active, the card title can include text and is displayed in the header above the table.
folderstringnullFolder name within Files library.
librarystring'Documents'Files library name.
record-idstringnullIf the component is used on a lightning record page, the page sets the property to the id of the current record.
show-cardbooleanfalseIf present, the table is wrapped in a lightning card to fit better into the overall page layout.
show-delete-actionbooleanfalseIf present, the last column contains a delete file action.
show-download-actionbooleanfalseIf present, the last column contains a download file action.
show-view-actionbooleanfalseIf present, the last column contains a view file action.

Usage ​

html
<c-content-document-table
  library="Documents"
  folder="Invoices"
  show-card
  show-view-action
  show-download-action
></c-content-document-table>

All attributes are also configurable in the Lightning App Builder, so no code is required to use the component.

Custom Labels ​

The texts users see are Custom Labels, so they can be translated in Setup with the Translation Workbench. Copy them together with the component.

NameValue
ContentDocumentTable_CreatedCreated
ContentDocumentTable_DeleteDelete
ContentDocumentTable_DownloadDownload
ContentDocumentTable_ErrorDeletingFileError deleting file
ContentDocumentTable_ErrorDownloadingFileError downloading file
ContentDocumentTable_FileDeletedFile deleted
ContentDocumentTable_LoadingLoading
ContentDocumentTable_SizeSize
ContentDocumentTable_SuccessSuccess
ContentDocumentTable_TitleTitle
ContentDocumentTable_ViewView
ErrorUtils_UnknownErrorUnknown error

Component Dependencies ​

NameTypeDescription
contentDocumentIconLWCCustom datatable cell type to display the appropriate icon based on the file type.
contentDocumentPreviewLWCCustom datatable cell type that is used to display a file preview when clicking on the title.
contentDocumentTableExtensionLWCCustom extension of the standard LWC datatable to support individual table cell types.
ContentDocumentControllerApexController class for retrieving content documents from files library.
ContentDocumentControllerTestApexTest class for ContentDocumentController.
errorUtilsLWCShared functions to read error messages and show error toasts.

Released under the MIT License. · llms.txt for AI agents