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
colemabcolemab 

Odd VisualforceException thrown from getcontent call. What does this error mean?

So I have a VF form that has file attachments.  Then I have a controller extension that uploads those files (with a catch/try/final for the insert) and then sends an email.   All of this has been working fine.  

 

Recently, I added a new page that renders as PDF (which works fine).   I added code to get this page's content and attach it to an email.   Now the getcontent call in the apex code throws the following exception:

 

System.VisualforceException: j_id0:GoodRootsApplicationForm:Main:DetailRequestInfo:j_id101:ProjectBudgetfile:inputFile:file

 

If I don't attach a file in the form, all of this works just fine (i.e. the pdf is correctly created and attached to the email that is sent).   I am using the finally block to set the file attachment to a new attachment (for view state purposes) after the insert occurs.

 

What does this error mean?  Does anyone else have a form with file upload that sends an email with a pdf attachment?

 

Thanks for any views and/or replies.

TejTej

Once i ran into this kind of exception, mine is because i have  "Required = true" in one of my visualforce component.

so i took that off and put the validation rule in my controller.

 

colemabcolemab

Tej,

 

Did that happen with a file or a field?  I ask because my file is 'required' via code in the controller and not on the page.

 

Thanks for the reply.

TejTej

mine is a field on the page, try taking of that validation in controller n see.

if thats the one causing issues, u can handle that validation in some other way

colemabcolemab

Great idea - I tried that earlier (great minds think alike right?).  If I remove the 'required' code for the attachment and don't attach a file, it works just fine but doesn't work if I do attach a file.

 

It is crazy that the exception references a file that isn't in the page called by the getcontent method call.  Also, this page (if passed ?id=<ID>) renders just fine by it self.

 

To add on top of that, the file in question gets set to a new attachment in the finally statement (after the attachment is inserted) to avoid view state limits.  I also tried setting the attachment to null prior to the call and that had no effect.  I thought setting it to null would be the same thing as not attaching it but that seems not to be the case.