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
Ash Jones 10Ash Jones 10 

Custom button "Create Quote" renders page as PDF & automatically attach the PDF under Notes & Attachments Section

Hi,
I have created a visual force page called "Create Quote" which gathers data from quote line items and creates a PDF page. I have created a button called "Create Quote" which works fine. I need to add the code so when this button is used, it can create a new attachment under attachments automatically. Can someone help me with this code?
The existing code looks like this.

<apex:page standardController="HPL_Pricing__c" renderAs="pdf" applyBodyTag="false">
<div class="header">
    <center><img src="{!$Resource.Logo}" width="25%"/></center>
    <center>P / N</center>
            </div>
  <apex:pageBlock title="HPL QUOTE REQUEST - {!HPL_Pricing__c.Name}">
Customer Account# <b><u>{!HPL_Pricing__c.Account__c}</u></b> <br/>
Customer Name: <u><b>{!HPL_Pricing__c.Distributor_oem__r.Name}</b></u><br/><br/>
Requested Date: <u><b>{!HPL_Pricing__c.Request_Date__c}</b></u><br/>
Project Information: <b>{!HPL_Pricing__c.Project_Information__c}</b><br/>
Request Type: <u><b>{!HPL_Pricing__c.Request_Type__c}</b></u><br/><br/>
Comments: <b>{!HPL_Pricing__c.Comments__c}</b><br/><br/>
</apex:pageBlock>
<apex:pageBlock title="Quote Information">
    <apex:dataTable value="{!HPL_Pricing__c.OEM_Quote_Line_Item__r}" var="quo" CellPadding="20" border="1">
        <apex:column headerValue="# of Sheets"> 
        <center><apex:outputText value="{!quo.Quantity__c}"/></center>
        </apex:column>
        <apex:column headerValue="Grade">
        <center><apex:outputText value="{!quo.Grade_Product__c}"/></center>
        </apex:column>
        <apex:column headerValue="Current List Price">
        <center><apex:outputText value="{!quo.Current_List_Price__c}"/></center>
        </apex:column>
        <apex:column headerValue="Project Price">
        <center><apex:outputText value="{!quo.Project_Price__c}"/></center>
        </apex:column>
        
            
    
    </apex:dataTable>
</apex:pageBlock>
<br/><br/>

Requested By: {!HPL_Pricing__c.CreatedBy.FirstName} {!HPL_Pricing__c.CreatedBy.LastName}<br/><br/><br/>
<apex:pageBlock title="Approval Comments">
</apex:pageBlock>

<apex:dataTable value="{!HPL_Pricing__c.OEM_Quote_Line_Item__r}" var="app">
 <apex:column >
{!app.Approval_Comments__c}
 </apex:column>
</apex:dataTable><br/><br/>
Approved By: {!HPL_Pricing__c.Approved_By1__c}

</apex:page>