function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RelaxItsJustCodeRelaxItsJustCode 

Need help attaching VF page to record as an attachment - lots of kudos

I will give any who contribute kudos.

 

For the purposes of making this as simple as possible.  Lets work with the following hello world VF page renderas PDF.

 

What I need to know is how to attach the PDF that this creates and automatically save it to the contract's notes and attachment section.

 

The name will always be HelloWorld1 for the file that is saved to the attachments section.

 

<apex:page standardController="Contract"  
         showHeader="false" 
         sidebar="false" 
         renderAs="PDF"
         title="ContractPDF.pdf">
         <head>
             <title>ContractPDF.pdf</title>
         </head>
         <apex:outputText value="Hello World"/>
 </apex:page>

 Please let me know the simplest way of taking the above and inserting into the notes and attachments related list on the Contract object.

 

Thank you,

Steve Laycock

RelaxItsJustCodeRelaxItsJustCode

Jeff's solution is a bit too clumsy for me.

 

I need the VF PDF to automatically save under the current contract in notes and attachment.

 

I gave you kudos for trying to help though.

 

Any other ideas?

 

Thank you,

Steve Laycock