+ Start a Discussion
Mike @ BlackTabMike @ BlackTab 

Dependent picklist like functionality not working correctly

I'm trying to create 3 custom dependant picklist:

 

Projects, Milestones, and Deliverables

 

The problem i'm having is refreshing the dependant picklists when a parent picklist value is chosen.

 

Here is the code I have so far:

 

VF:

 

<p>Related To:</p>
          <apex:selectlist value="{!projectID}" multiselect="false" size="1">
              <apex:selectOption itemvalue="" itemLabel="--Open Projects--" />
              <apex:selectoptions value="{!openProjects}"/>
              <apex:actionsupport event="onchange" rerender="milestoneList"/>
          </apex:selectlist>
          <apex:selectlist value="{!milestoneID}" multiselect="false" size="1" id="milestoneList">
              <apex:selectOption itemvalue="" itemLabel="--Milestones--" />
              <apex:selectoptions value="{!RelatedMilestones}"/>
          </apex:selectlist>
          <apex:selectlist value="{!deliverableID}" multiselect="false" size="1">
              <apex:selectOption itemvalue="" itemLabel="--Deliverables--" />
              <apex:selectoptions value="{!RelatedDeliverabiles}"/>
          </apex:selectlist>

 

Apex:

 

public String projectID {get; set;}
    public String deliverableID {get; set;}
    public String milestoneID {get; set;}    

public List<SelectOption> getOpenProjects() {
        List<SelectOption> options = new List<SelectOption>();
        List<Project2__c> projects = [SELECT Name, ID FROM Project2__c WHERE Status__c != 'Completed' ORDER BY Name];
        
        for(Project2__c p : projects){
            options.add(new SelectOption(p.ID, p.Name));
        }
        
        return options;
    }
    
    public List<SelectOption> getRelatedMilestones() {
        List<SelectOption> options = new List<SelectOption>();
        List<Milestone_NEW__c> milestones = [SELECT Name, ID FROM Milestone_NEW__c WHERE Project__c = :projectID ORDER BY Name];
        
        for(Milestone_NEW__c m : milestones){
            options.add(new SelectOption(m.ID, m.Name));
        }
        
        return options;
    }
    
    public List<SelectOption> getRelatedDeliverabiles() {
        List<SelectOption> options = new List<SelectOption>();
        List<Deliverable__c> deliverables = [SELECT Name, ID FROM Deliverable__c WHERE Milestone_NEW__c = :milestoneID ORDER BY Name];
        
        for(Deliverable__c d : deliverables){
            options.add(new SelectOption(d.ID, d.Name));
        }
        
        return options;
    }