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
SoozeeSoozee 

issues with getContent()

Hi, I have an Apex class that creates a PDF attachment for each id that it is passed.

This works great when only 50 or so IDs are passed in, but any more than that and I get a Heap error.

 

I read somewhere that I could create a webservice in Apex to get around this, but I can't find any documentation about calling a salesforce webservice from within the same salesforce org.

 

If anyone can point me in the right direction, or suggest a different solution, that would be greatly appreciated!

Best Answer chosen by Admin (Salesforce Developers) 
SoozeeSoozee

I wasn't able to figure out a way around it, so I am just limiting the PDF creation to 100 records at a time.

All Answers

h8r41dh8r41d

You could use a class that implements Database.batchable.

 

You basically schedule a batch job to run on its own, say, 50 records at a time, to avoid hitting the ceiling limits.

 

See this page for a more detailed explanation:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm

 

If you need any technical help, feel free to give us a ring.

 

Gabriel Alack
Contact Us - We Can Help!

Salesforce Superheroes
------------------------------
help@salesforcesuperheroes.com
www.salesforcesuperheroes.com
1-888-407-9578 x122

 

SoozeeSoozee

Hi.  Thanks, but getContent() is not supported in Batch Apex.  So, that won't work.

h8r41dh8r41d

Did you see this page?

 

http://stackoverflow.com/questions/9404751/why-are-html-emails-being-sent-by-a-apex-schedulable-class-being-delivered-with

 

Gabriel Alack
Contact Us - We Can Help!
Salesforce Superheroes
------------------------------
help@salesforcesuperheroes.com
www.salesforcesuperheroes.com
1-888-407-9578 x122

SoozeeSoozee

I wasn't able to figure out a way around it, so I am just limiting the PDF creation to 100 records at a time.

This was selected as the best answer