1

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>
1
  • <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>
    – jen
    Commented May 2, 2014 at 13:58

1 Answer 1

2

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.

1
  • Your answer is technically correct but I don't think it'll help much ;) Consider posting some links to documentation like salesforce.com/us/developer/docs/pages/Content/… or maybe even showing a small sample in your answer? I suspect Jen doesn't know how to iterate over Contact.Credits__r relationship (assuming that's the name) so the raw names of tags won't help much
    – eyescream
    Commented May 2, 2014 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .