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
Dimitar Dimitrov 34Dimitar Dimitrov 34 

How to display data from related records in Visualforce List Page.

Hi all,
I hope you are well.

I have a Custom Controller and Visualforce Page.
The Controller is retrieving all data from Object "Call Sample" and is displaying it on the VF page. However the users want to see data from Object "Sample Transaction", but it is not related by Lookup or Master-Detail Relationship. The only connection is 2 text fields on "Sample Transaction", that are available on "Call Sample".

Is it possible for each line of the object "Call sample" to display data from "Sample Transaction" without hitting some SOQL Limits?

Please find attached a screenshot of the VF page, if needed I can add some code from the Controller and the page, but it is a lot.

Call Sample VF Page

Kind regards,


ANUTEJANUTEJ (Salesforce Developers) 
Hi Dimitar,

Generally, In case if they are related you can easily fetch records from both the objects using a single soql query but as you have mentioned they are unrelated I think you might have to run more than one separate query to get the required records.

Can you mention if they have a lookup field or any sort of field.

You can try checking as this seems to have a similar implementation requirement.

Dimitar Dimitrov 34Dimitar Dimitrov 34

Thank you for your reply.

The objects are not related by Lookup Relationship.

Something that was on my mind was to have a query:

SimpleTransaction = [SELECT id, Name, requested_filed1, requested_field2
                                   FROM Sample_Transaction_vod__c
                                   WHERE Call_Name IN [SELECT Call_Name FROM CallSampleRecord]
                                   AND Sample_Name IN [SELECT Sample_Name FROM CallSampleRecord]
                                   LIMIT 50000;

Something like that from above would work. Then I would put the retrieved records in Map<SampleID, SampleTransactionObject>, and display that in the Visualforce page.
Unfortunately, we have more than 50000 Call Sample records and SampleTransaction records - so I think this is not an option.

Kind regards,