0

I have a method that call a vf page and render as pdf the following

Pagereference test = new Pagereference ('/apex/claire');
return test;

that gives me the page I am expecting

enter image description here

after that the method is supposed to save the attachment to my custom object :

boite1 = listakta[i].Type_of_alert__c;
boite2  = listakta[i].text1__c;    
boite3 = listakta[i].comment__c;
boite4 = listakta[i].date__c;
PageReference pdf = new PageReference('apex/claire');              
Attachment attach = new Attachment();
pdf.getParameters().put('boite1', boite1);
ID accID = apexPages.currentPage().getParameters().get('Id');
parent= listakta[i].id;
body = pdf.getContentaspdf();
attach.Body = body;
attach.Name = 'test1.pdf';
attach.IsPrivate = false;
attach.ParentId = parent;
insert attach;

Unfortunately when it saves the data, it does only save the vf page (claire) without the dynamic content

enter image description here

Where the dynamic content is boite1, boite2, boite3 and boite4

So the problem is that the page is generated nicely and work, but the attachment is not loading the data that created before. (not synchronous)

Please help me as I tried so many things and it's not working

  • Is there a reason you are using new PageReference('apex/claire') instead of just Page.claire? I don't see why you need to use a partial URL since you are not redirecting to this page. – David Cheng Aug 12 '19 at 14:25
  • That doesn't change the problem of the dynamic data not loading @DavidCheng – Tibgg Aug 13 '19 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.