You need to sign in to do that
Don't have an account?
vcv
Populate multiple picklists with records from three different custom objects
I have three related objects and I wanto to populat picklists with records from different fields.
Example: Object1__c.Name__c (text field) Object2__c.AvailableAppointments__c (date), Object3__c.AppointmentDuration (minutes).
The following code works fine, however it only displays the picklist for Object1__c.Name__c. How can I add two additional picklists with values from Object2 and Object3 fields?
VF:
<apex:page controller="sampleCon"> <apex:form > <apex:selectList value="{!strSelected}" multiselect="false" size="1"> <apex:selectOptions value="{!options}"/> </apex:selectList> </apex:form> </apex:page>Controller:
public class sampleCon { public String strSelected {get;set;} public List<SelectOption> options {get;set;} public sampleCon() { strSelected = ''; options = new List<SelectOption>(); for(Object1__c obj :[SELECT Name FROM Object1__c]) { options.add(new SelectOption(obj.Id,obj.Name)); } } }
All Answers