Skip to content

Instantly share code, notes, and snippets.

@recalde
Created September 30, 2011 14:22
Show Gist options
  • Save recalde/1253878 to your computer and use it in GitHub Desktop.
Save recalde/1253878 to your computer and use it in GitHub Desktop.
Salesforce showFilePreview
<!-- This is an example of how to use the function -->
<a id="Title_069Q00000006bam" href="javascript:showPreviewDialog('069Q00000006bam', 'Title_069Q00000006bam', 'PDF');">Cover Sheet</a>
<!-- This is the javascript -->
<script type="text/javascript">
function showPreviewDialogForContentDocument(contentDocumentId, titleElementId) {
var query = "SELECT Id, ContentDocumentId, FileType, CreatedDate ";
query += "FROM ContentVersion ";
query += "WHERE ContentDocumentId = '" + contentId + "' ";
query += "ORDER BY CreatedDate DESC LIMIT 1";
var record = sforce.connection.query(query).records;
showPreviewDialog(record.Id, titleElementId, record.FileType)
}
function showPreviewDialog(contentVersionId, titleElementId, fileFormat) {
OverlayDialogElement.showFilePreview(
'docViewerOverlay',
titleElementId,
'/_swf/121310/sfc',
contentVersionId,
'chatter_bubble',
'false',
'docViewerContainer',
false,
fileFormat,
false);
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment