function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Francisco Riccomagno 1Francisco Riccomagno 1 

Show information from related object in VisualForce

Hi all. Im creating a wizard with VisualForce were, to put an example, I'm populating information from a Customer and the product it bought. So, in the first step we load the information related to the Customer (Customer__c), in the second page we load the information for each of the product he/she bought (Product__c), and in the third page I want to show the summary of all this steps.
So, my problem comes at this step, were I want to show, for each of the products, the Product Type (Product_Type__c) they belong to (information that was loaded though a lookup in the step 2).
so, the Visualforce code that I'm trying to use is:

<apex:repeat value="{!products}" var="item">
   <apex:outputText value="Article Number"/>
   <apex:outputText value="{!item.Article_Number__c}"/>
   <apex:outputText value="Product Type"/>
   <apex:outputText value="{!item.Product_Type__c.Name}"/>
</apex:repeat>

When trying to save this I get: Error: Unknown property 'String.Name'
When I remove the .Name, what I'm showing is the Id of the Product_Type__c chosen.
So, how can I iterate through the list of product and for each of it show the Product_Type__c.Name ?
Thank you in advance!
Daniel B ProbertDaniel B Probert
try Product_Type__r.Name

note the r tells salesforce it's a related name.

thx
dan
Francisco Riccomagno 1Francisco Riccomagno 1
It doesn't work, becuase it seems that the relationship does not exists until the object is saved, so in that place is showing a blank field. I know the Product Type Name exists, because is what is shown in the lookup.
Daniel B ProbertDaniel B Probert
hmm ok you'll need to possibly use transaction control in your apex for the vf to manage this then - that way the relationship should be establish and in the event you change your mind you can do a rollback.

this might help:

https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_transaction_control.htm
Francisco Riccomagno 1Francisco Riccomagno 1
Mmm, I don't think this should be the solution to show the summary information. There should be a way of showing this information before saving it.