You need to sign in to do that
Don't have an account?
Calling a Class the attaches a PDF Document from a VF Page.
Hi there,
This is my code that is calling another CLASS.
<apex:page standardController="Opportunity" extensions="ClsIntel_AttachIBQuotePDF" action="{!attachIntel_ViewIBQuote_Attach}">
<!-- Get Opportunity ID & Name -->
{!Opportunity.Id}
{!Opportunity.Name}
</apex:page>
My question is - What does this action signify?
action="{!attachIntel_ViewIBQuote_Attach}">????
I basically need to attach a PDF Document to a Opportunity on a click of a button. I have already developed another Visualforce page which is rendering as PDF. that one works well. I just want that same PDF to now get it attached to the Oppty when the user clicks on another button.
What should I write in the *attach*, is it the name of Class that I just create which is attaching the PDF Document or is it name of the page which is getting rendered as a PDF Document.?
I am getting this error message:-
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Error: action="{!attachIntelView_IBQuote}": Unknown method 'OpportunityStandardController.attachIntelView_IBQuote()'
///////////////////////////////////////
What am i missing?
Please help. I am new to this, and really lost.
Thanks.
The action attribute of the <apex:page> calls a method in your controller on page load. If you want a button to attach a pdf, you would have to create a PageReference variable that is your pdf page in a method, save the body of it to a blob and add it to an attachment with the Opportunity as the parent and pdf as the type.
For example:
public void attachPDF()
{
PageReference pageRef = Page.TestPDF;
// You use the line below because it will render your page as a PDF regardless of what you set the page as
Blob b = pageRef.getContentAsPDF();
Attachment att = new Attachment();
att.Body = b;
att.Name = 'Test name.pdf';
att.ContentType = 'pdf';
att.ParentId = opp.Id; // Assuming you set this somewhere in your class
insert att;
}
This method will save your page as a pdf with any name you would like!
I hope this helps
----
Dominic
Thank you.
I figured it out later, that the action should represent the method in the class name - the extension class name that I had created.
Thanks for the reply.