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
Aam MAam M 

How to fetch other object records in to other VF Page

I've one VF page & used standardController to save the records of that Custom Object that is used in standardController..
But I want to display other Custom object data in that VF Page for some use I have to hide those field.
But How should I fetch other object records to this VF Page .

Any Help will be appreciated!

Shruti SShruti S
You can use the extensions attribute of <apex:page> tag to achieve this. In the extensions, you can create a new class and in that you can write the code achieve your requirement. Here is a link to know more about Extensions in Salesforce -
Ajay K DubediAjay K Dubedi
Hi  Mujahid Ahmed,

Try this Code
In this visualforce page I have two Salesforce Custom Objects.[Vehicle__c and Manage_Hello__All_City__c] and showing data for both of the Object. For showing Vehicle__c records I have used standardController and Manage_Hello_All_City__c I am using extensions.
VisualForce Page Code:-
<apex:page standardController="Vehicle__c" recordSetVar="Vehicle__c"  extensions="ShowCustomRecordVehicle"> 
    <apex:form >
                      <table  width="100%" border="2">  
                            <th>Vehicle Name</th>
                            <th>Vehicle Location</th>
                            <th>Vehicle Phone Number</th>
                            <th>Vehicle State</th>
                            <th>Vehicle Model</th>
                    <apex:repeat value="{!Vehicle__c}" var="veh">
                          <td> {!veh.Name} </td>          
                          <td> {!veh.Location__c} </td>
                          <td> {!veh.Phone_Number__c} </td>
                          <td> {!veh.State__c}</td>
                          <td> {!veh.Vehicle_Model__c} </td>
               <table  width="100%" border="2">
                   <th><center>2nd Custom Object only five Field Show Through Controller</center></th>
                  <th> City Name</th>
                    <th>Pin Code</th>
                      <apex:repeat value="{!AllList}" var="All">
                          <td> {!All.Manage_Hello__City_Name__c} </td>          
                          <td> {!All.Manage_Hello__Email__c} </td>
                          <td> {!All.Manage_Hello__Movies__c} </td>
                          <td> {!All.Manage_Hello__Pin_Code__c} </td>

Controller Code:- 
public class ShowCustomRecordVehicle 
     public list<Manage_Hello__All_City__c> AllList{get;set;}
    public ShowCustomRecordVehicle(ApexPages.StandardSetController controller) 
AllList=[select Manage_Hello__City_Name__c,Manage_Hello__Email__c,Manage_Hello__Movies__c,Manage_Hello__Pin_Code__c from Manage_Hello__All_City__c Limit 5];

User-added image

If this answers your query please mark this question as a solved so that it can be filtered out from  unsolved questions.
Aam MAam M
Hi Ajay..

Actually my requirement is I've created VF page to save custom object records. But I need to display alert if any condition is met! in that condition there is another custom object data is related, so how can I bring those object data in to this VF page so that i can check condition

User-added image

So please look at the picture,, in this VF page I've to bring alert box when I click save if condition se met, in that condition I've to get details from Policy object(see in the tabs) How to achieve this ??

help needed!!