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
@login.ax974@login.ax974 

Exception while calling getContent()

Hi,

 

 I am trying to get the content from a VF page and store it as an attachment. So i am doing below:

 

PageReference pg = new PageReference('/apex/myDoc?oppId=' + oppId);

pg.setRedirect(true);

 

Attachment att = new Attachment();

att.Body = pg.getContent(); <--- Here i get java.net.SocketException: Connection reset but it is intermittent and not reproducible.

 

Any idea why is this happening?

 

Thanks for the help!!

 

 

Dirk GronertDirk Gronert

Can you pls provide more information, like where are you sung this code?

@login.ax974@login.ax974

Hi,

 

 This is used for dynamically generating a PDF document from the values on the opportunity object and also saving the same PDF as an attachment to the opportunity record.

 

Thanks.

Dirk GronertDirk Gronert

In a controller?!

@login.ax974@login.ax974

Yeah thats right.