You need to sign in to do that
Don't have an account?
Trouble displaying Fields From Different Objects on my VF Page
Hello,
I have a custom "Pipeline Tracker" object with a lookup relationship to the "Account" object. I am trying to run a test where I display all my records, pulling 1 field from the "Pipeline Tracker" object and 1 field from the "Account" object.
I am trying to do this by putting everything into a list, which I hope to call on my VF page. I haven't gotten any errors in building my list.
List <Account> pipelineRecords = new List <Account> (); public void buildList() { for (Account acct: [SELECT Sales_Pole__c, (SELECT Category__c FROM Pipeline_Tracker_3__r) FROM Account]) { pipelineRecords.add(acct); } } public List<Account> getpipelineRecords() { return pipelineRecords; }
On my VF page, I have a simple test where I simply want to call every record from my list and display the "Sales Pole" field from the "Account" object and the "Category" field from the "Pipeline Tracker" object.
Here is the code I have on my VF page.
<apex:page controller="MultipleDBJoin"> <TABLE> <TH>Category</TH> <TH>Sales Pole</TH> <apex:repeat value="{!pipelineRecords}" var="a"> <TR><TD width="75"><apex:outputText value="{!a.Category__c}" /></TD> <TD width="100"><apex:outputField value="{!a.Sales_Pole__c}" /></TD></TR> </apex:repeat> </TABLE> </apex:page>
I am getting an error saying that Category C is not found on the Account object. I think the problem lies in my List Creation where I specified my List as the Account type. But, it wouldn't let me create a List unless I established it with an object type, and if I set the List as the object type: Pipeline_Tracker_3__c, I would still get an error with Sales Pole.
Does anyone know how I can work around this issue? Can I create an SObject instead and iterate through that in order to display each record?
Thanks
Mike
Seems like you should be able to reference the category field as
{!a.pipeline_tracker_3__r.category__c}
You should use a wrapper class :
VFP
I hope above example helps you in this you will only be able to show only single record of Pipeline_Tracker_3__c object. If you want to show all then pass list of Pipeline_Tracker_3__c and use a repeat in VFP.