You need to sign in to do that
Don't have an account?
M Miller
Showing Products on a Visualforce page
I am working on a visualforce page with the Account standard controller, and am pulling in fields from the Account, Contact, and Opportunity objects with no problem. My problem is that I also need to show the associated Products, but I can't for the life of me figure out how to do this. The way I brought in contact and opportunity fields associated with an account (apex:pageblocktable value="{!Account.contacts}" var="contact") isn't working for associated products. When I set up (apex:pageblocktable value="{!Account.products}" var="product") or any variation like productitems or opportunityproducts, I get an error message of "Invalid field for sObject Account".
I'm really new to Visualforce, and am struggling to understand why this is such a problem! Is there any way to get the name of a product on my VF page?
I'm really new to Visualforce, and am struggling to understand why this is such a problem! Is there any way to get the name of a product on my VF page?
For other beginners like me, who also benefit from having the obvious stated:
Note that the __r specifies that it's a related list, and the __c specifies that it's a custom field from that related list.
This is also a great way to only bring in certain fields from a related list - I was originally putting in <apex:relatedlist list="product_items"/>, but that copied over EVERYTHING from the related list view, including the edit and delete links, fields I didn't want, and the buttons along the top. Not the greatest view for a static report.