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
madhu l 1madhu l 1 

when i open my object appear dropdown list for all account names in that object how

Andy BoettcherAndy Boettcher
You will need to create a Visualforce page with an Apex controller to do this - in the controller, you will create a List<SelectOption> GETTER that queries for those accounts and then displays those accounts in an apex:selectlist.
Jai ChaturvediJai Chaturvedi
Hi,
 
<apex:page Controller="togetaccounts">
    <apex:form >
            <apex:pageBlock >
                    <apex:selectList id="accts" value="{!Contact.AccountId}" size="1" title="Account">
                             <apex:selectOptions value="{!accts}"></apex:selectOptions>
                   </apex:selectList>
          </apex:pageBlock>
  </apex:form>



public List<selectOption> getaccts() {
    List<selectOption> options = new List<selectOption>(); 
    //new list for holding all of the picklist options
    options.add(new selectOption('', '- None -')); 
    //add the first option of '- None -' in case the user doesn't
    want to select a value or in case no values are
    returned from query below
    for (Account account : [SELECT Id, Name FROM Account]) { 
    //query for Account records 
    options.add(new selectOption(account.id, account.Name)); 
    //for all records found - add them to the picklist options
    }
    return options; //return the picklist options
}

Mark this as solution if helps.


Thanks
Jai
Jai ChaturvediJai Chaturvedi
Modifying above code.
 
<apex:page Controller="togetaccounts">
    <apex:form >
            <apex:pageBlock >
                    <apex:selectList id="accts" value="{!selectedAccoutnName}" size="1" title="Account">
                             <apex:selectOptions value="{!accts}"></apex:selectOptions>
                   </apex:selectList>
          </apex:pageBlock>
  </apex:form>



public List<selectOption> getaccts() {
    List<selectOption> options = new List<selectOption>(); 
    //new list for holding all of the picklist options
    options.add(new selectOption('', '- None -')); 
    //add the first option of '- None -' in case the user doesn't
    want to select a value or in case no values are
    returned from query below
    for (Account account : [SELECT Id, Name FROM Account]) { 
    //query for Account records 
    options.add(new selectOption(account.id, account.Name)); 
    //for all records found - add them to the picklist options
    }
    return options; //return the picklist options
}