Created
May 2, 2017 05:46
-
-
Save douglascayers/95717267071c674ca8ea157e11039862 to your computer and use it in GitHub Desktop.
Proof of concept inspired by Matthew Hauck's question on the Success Community how to export Enhanced Note to PDF, https://success.salesforce.com/0D53A000035M8cM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Developed by Doug Ayers (douglascayers.com) | |
| * | |
| * Proof of concept inspired by Matthew Hauck's question | |
| * on the Success Community how to export Enhanced Note to PDF | |
| * https://success.salesforce.com/0D53A000035M8cM | |
| */ | |
| public with sharing class ContentNotePDFController { | |
| public transient String title { get; set; } | |
| public transient String content { get; set; } | |
| public ContentNotePDFController( ApexPages.StandardController stdController ) { | |
| ContentNote note = [ SELECT id, title, content FROM ContentNote WHERE id = :stdController.getId() ]; | |
| this.title = note.title; | |
| this.content = note.content.toString(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Developed by Doug Ayers (douglascayers.com) | |
| * | |
| * Proof of concept inspired by Matthew Hauck's question | |
| * on the Success Community how to export Enhanced Note to PDF | |
| * https://success.salesforce.com/0D53A000035M8cM | |
| */ | |
| @isTest | |
| private class ContentNotePDFControllerTest { | |
| @isTest | |
| static void test_controller() { | |
| ContentNote cn = new ContentNote( | |
| title = 'Test Title', | |
| content = Blob.valueOf( 'Hello World' ) | |
| ); | |
| insert cn; | |
| Test.startTest(); | |
| ContentNotePDFController controller = new ContentNotePDFController( new ApexPages.StandardController( cn ) ); | |
| Test.stopTest(); | |
| System.assertEquals( 'Test Title', controller.title ); | |
| System.assertEquals( 'Hello World', controller.content ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <apex:page title="{!title}" standardController="ContentNote" extensions="ContentNotePDFController" renderAs="pdf" readOnly="true" cache="false"> | |
| <h1> | |
| <apex:outputText value="{!title}"/> | |
| </h1> | |
| <apex:outputText value="{!content}" escape="false"/> | |
| </apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment