+ Start a Discussion
Akhil R NathAkhil R Nath 

Hi All, I want to display the Objects(Account, Leads, Opportunity, Contacts) with record details on visualforce page. I have added selectoption to choose the object when clicking on the object it has to display the corresponding record details.

public class mycontroller {
    public string currentobject {get; set;}
    public string currentfield {get; set;}
    public String Items {get;set;}
    //List<account> AccountToDelete = new List<account> ();
    public List<Contact> conlist {get;set;}
    //public List <sObject> conlist {get;set;}

            
        public List<SelectOption> getobjects() {
       List<SelectOption> objects = new List<SelectOption>();
       objects.add(new SelectOption('','Select'));
       objects.add(new SelectOption('Account','Account'));
       objects.add(new SelectOption('Lead','Lead'));
       objects.add(new SelectOption('Opportunity','Opportunity'));
       objects.add(new SelectOption('Contact','Contact'));
            system.debug('objects'+objects);
            
       return objects;


<apex:page controller="mycontroller">
    <apex:form id="form">
        <apex:pageBlock >
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Objects</apex:outputLabel>
                    <apex:selectList size="1" value="{!currentobject}">
                        <apex:selectOptions value="{!objects}"/>
                        <apex:selectOptions value="{!Items}"/>
                        
                        <apex:actionSupport event="onchange" action="{!getobjects}" reRender="form"/>
                        
                        
                         
                
                    </apex:selectList>
                                           
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            
                

        </apex:pageBlock>
    </apex:form>
</apex:page>

Can anybody help with the logic?
ANUTEJANUTEJ (Salesforce Developers) 
Hi Akhil,

Generally, we would be accessing all the records via UI by navigating. 

You can write a custom controller to get the records according to the selected option.

Regards,
Anutej