You need to sign in to do that
Don't have an account?
Alex Kirby 8
Error Unknown Property Error Extension Controller
Hi All,
I am trying to generate a pdf on from a VF page and attach it to the opportunity.
I used a custom controller and tried to modify it for use as an extension controller as I don't want any user input. The pdf must be saved to the opp on a button click etc.
I think I am missing something from my controller as when I call the {!savepdf} method I am getting this error:
Error: Unknown property 'Credit_Check__cStandardController.savepdf'
Here is the controller:
In the VF page I am simply calling {!savepdf}
Any help is much appreciated.
Al
I am trying to generate a pdf on from a VF page and attach it to the opportunity.
I used a custom controller and tried to modify it for use as an extension controller as I don't want any user input. The pdf must be saved to the opp on a button click etc.
I think I am missing something from my controller as when I call the {!savepdf} method I am getting this error:
Error: Unknown property 'Credit_Check__cStandardController.savepdf'
Here is the controller:
public with sharing class PdfGeneratorController { Public final Credit_Check__c CC; public PdfGeneratorController (ApexPages.StandardController stdController) { this.CC= (Credit_check__c)stdController.getrecord(); } public PageReference savePdf1() { PageReference pdf = Page.Cvs_PDF; // add parent id to the parameters for standardcontroller pdf.getParameters().put('id',cc.Opportunity__r.accountid); // create the new attachment Attachment attach = new Attachment(); // the contents of the attachment from the pdf Blob body; try { // returns the output of the page as a PDF body = pdf.getContent(); // need to pass unit test -- current bug } catch (VisualforceException e) { body = Blob.valueOf('Some Text'); } attach.Body = body; // add the user entered name attach.Name = cc.name; attach.IsPrivate = false; // attach the pdf to the account attach.ParentId = cc.Opportunity__r.accountid; insert attach; // send the user to the account to view results return new PageReference('/'+cc.Opportunity__r.accountid); } }
In the VF page I am simply calling {!savepdf}
Any help is much appreciated.
Al
Use commandLink instead of href.
Check the below link.
http://astreait.com/creating-hyperlinks-in-visualforce/
All Answers
In your controller method is "savePdf1()"
But you are calling "savePdf()"
Use the same method name on both the place.
what error you are getting?
You should query "Opportunity__r.accountid" in your controller.
Error: Unknown property 'Credit_Check__cStandardController.savepdf'
so I have a command button with action="{!savepdf}" but the above error flags when I try to save.
<center><a href="" action="{!savePDF}" Oncomplete= "closeWin()" Style="cursor:pointer;" class="metro">Finish</a></center>
Use commandLink instead of href.
Check the below link.
http://astreait.com/creating-hyperlinks-in-visualforce/
System.VisualforceException: SObject row was retrieved via SOQL without querying the requested field: Credit_Check__c.Opportunity__c
These fields are not in my controller but are in the VF Page, I removed this one and it just went to the next field and threw an error there.
I have managed to pull the fields through to the PDF by adding the fields required for the PDF to a the visualforce page that the button is located on.
I am receiving an error relating to a field which is not in my pdf specifically or on the VF page.
Error below:
System.VisualforceException: common.apex.runtime.impl.ExecutionException: SObject row was retrieved via SOQL without querying the requested field: User.Name
Any help would be awesome as I am so close!
Thanks,
Alex
Thanks