You need to sign in to do that
Don't have an account?
Visualforce within Scheduled Apex
We have a working process where the user submits a Visualforce form which causes a Visualforce PDF to be created and emailed to the user. We want the same PDF generation/email to happen on a daily schedule. So we have made some changes to invoke similar functionality via the Apex Scheduler. The scheduled class runs without any error messages and a PDF email gets sent, but the PDF is unable to be opened (indicating that something went wrong in the Visualforce rendering of it).
We have tested the functionality using anonymous execute and it works fine. Seems to be a problem related to it being run by the scheduler. Is there a limitation where you can't invoke Visualforce (new PageReference / getContent()) from within a scheduled Apex class?
As noted above, getContentAsPDF is not supported for scheduled Apex. We'll be updating the docs to state this more clearly. Thanks for bringing this to our attention.
...stephan