I'm trying to create a page in memory so that I can get the content. The problem I'm having is that the code expects there to be a record (case) associated with it but I need to provide the URL to a VisualForce page and some other parameters as well. If I set the URL in the constructor of the PageReference, it doesn't resolve the record. How do I both get the record associated and set the URL to a VisualForce page?
String strUrl = '/apex/MyApexPage?id=' + myCase.Id + '¶meter=' + myParm; PageReference pr = new PageReference( strUrl ); Attachment att = new Attachment( Name = 'myAttachment' ); att.Body = pr.getContent();
I then end up with an exception that there are no rows returned for the page I'm trying to get because in its code, it looks something like:
What do I need to do to get this all to work?
Case theCase = stdContrller.getRecrod(); Case myCase = [SELECT Id, CaseNumber, CreatedDate, CreatedById FROM Case WHERE Id = :theCase.Id];