You need to sign in to do that
Don't have an account?
Create a PDF from record and records on related object
Hi guys,
I am trying to create a PDF file just like Quotes work. However im doing this from a Custom Object.
I found this link that answers it in some way :
https://developer.salesforce.com/forums/?id=9060G000000I7qhQAC
However im looking to create a pdf with some info from the record that is being created and the Line Items on the quote will come from data on records which this main record is related to.
Better explaining, i have Object A which will have the button to create the PDF, some of the main data will be pulled from the record on Object A, the line items(which may be just one or many, based on a criteria that i also want to specify) will pull from Object B, which has a lookup field to Object A on every record on the org.
So the PDF will generate with info from OBject A and every Object B that has object A related and meeting the criteria.
Lastly i want a second button that will create the PDF but will attach the PDF to an email with a preselected templated(email template created on salesforce) and automatically send it to the email on a contact lookup field on Object A.
Please advise the best way to create this procedures.
I really appreciate your help!
i can point you to another post where similar requirement was discussed, though the question is not closed but still points in the right direction
https://developer.salesforce.com/forums/?id=906F0000000D8wXIAS
in this post, venkat-d mentioned
"you can create a custom button on the parent object. Please follow below process .
1. Create a vf page with the format you need for child records
2. Create a cutom javascript button that calls a class method.
3. In the class instantiate the vf page created in 1 and do getcontent()
4. Create a new attachment variable with body as the response from getcontent()
5. Attach the attchment to parent record
6.send email using the same info to requried users."
if you need code help, then let me know, i will try to replicate it my dev org n post it here.
cheers,
Dev
I have made some progress on what to do.
I figured out on how to render my HTML as a PDF from my record on a custom object.
However,
im stuck on how to pull the data from the record. keep in mind this is a custom object so im thinking i need to create a class and go from there.
Ive been trying to research on class development but im a bit stuck.
Any help will be truly appreciated.
I am sorry, I could not work on it, over the weekened we got stuck with some deployment issues and then I got sick.
I hope you have solved your problem so far, otherwise lets see what we have so far. I believe from your custom button, using JS you are calling Apex Class Function, where you get the record Id and can generate the pdf using PdfGenerator Template.
In the same function u can also get the record details. Below is the pseudo code, I just wrote it on the fly. You may need to edit it a lot.
I hope this helps. And appologies again for the delayed response.
Cheers,
Dev
I was not able to understand the way to go on the code you posted.
For you to familiarize and be able to explain me a bit better, here is where i am so far:
"<apex:relatedList list="CanaryAMS__Carrier_Quotes__r" />" will give me what shows on that related list exactly as it shows on my record.
I am actually trying to use some of the fields of the related records that meet certain criteria in the vf page.
that the step i am precisely blocked at.
again, THANK YOU so much for your help.