I have a custom object called Credits that is related to Contacts via lookup relationsihp.
I added a button in the Contact page that displays a pdf of the credits for that specific contact.
I know the apex to display a page as pdf but unsure how I can display Credits only for that contact? Do I need a controller? How do I pass the value of the contact ID to the page?
<apex:page standardController="Credits__c" showHeader="false" renderAs="pdf">
<apex:pageBlock title="Credits">
<table>
<tr>
<td width="15%"><apex:outputLabel value="Course Number: " for="coursenumber" /></td>
<td width="35%"><apex:outputField id="coursenumber" value=" {!RITT_Credits__c.Course_Number__c}"/></td>
</tr>
</table>
</apex:pageBlock>
</apex:page>
Attribution to: jen
Possible Suggestion/Solution #1
The standard controller (the one you have now) should work fine for your purposes here. You'd pass the contact ID to the page like this:
https://ssl.salesforce.com/apex/YourVFPageName?id=YourID
There's a number of ways you could display just the Credits, but apex:relatedList might be the simplest. Apex:pageBlockTable is another possibility. For more control over the appearance, use apex:datatable.
Attribution to: Jagular
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34248