Skip to main content
Baird Straughan が「#Visualforce」で質問
I have set up some dependent picklists which I've confirmed work as expected in the Salesforce environment (these are Opportunityfields and they work well on Opportunity layouts).  An example is a State picklist which then defines the list of counties that display in the County picklist.  I'm trying to use these on a visualforce page so that volunteers (not SF users) can submit data, but the dependent picklists are not being limited by the selection of the controlling picklist.

We appear to be using API version 33.  Relevant code for the VF page uses apex:inputField and is:

 

<tr>

<td width="100px" align="left" valign="top"><font face="georgia" ><b><apex:outputLabel value="State" /></b></font></td>

<td align="left" valign="top"><apex:inputField value="{!opp.Location_State__c}" /></td>

<td width="100px" align="left" valign="top"><font face="georgia" ><b><apex:outputLabel value="County (if applicable)" /></b></font></td>

<td align="left" valign="top"><apex:inputField value="{!opp.Location_County__c}" /></td>

</tr>

The page uses a custom controller written for this purpose.  The relevant portion of the controller (I believe) is:

public class enterServiceProjectController {

public enterServiceProjectController() {

ServiceProjectId = [select id from RecordType where name = 'Service Project'][0].id;

AdvancedTrainingId = [select id from RecordType where name = 'Advanced Training'][0].id;

SelectedPartners = new list<Account>();

//AllOrgs = new List<Id>();

ListPartners();

SetUpOpp();

ctct = new Contact();

accountToDeleteId = '';

ListPartners();

}

public contact ctct {get;set;}

public account acc {get; set;}

public opportunity opp {get;set;}

public string SelectedPartner1 {get;set;}

public string SelectedPartner2 {get;set;}

public string SelectedPartner3 {get;set;}

public boolean ContactNotListed {get;Set;}

public Id ServiceProjectId{get; set;}

public Id AdvancedTrainingId{get;set;}

public string ChosenRTId {get; set;}

//public list<Id> AllOrgs {get; set;}

public map<string,account> Partnermap {get; set;}

public list<selectOPtion> Partners {get;set;}

public list<Account> SelectedPartners {get; set;}

public boolean IsThisWorking {get; set;}

public string accountToDeleteId {get; set;}

public PageReference submitVol() {

ContactNotListed=false;

LIST<String> person = identifyPerson.identifyPerson(ctct);

if (person == null) {

ContactNotListed = true;

return null;

} else {

if (person[1]=='Contact') {

ctct.id = person[0];

acc = [select id from Account where id = :[select accountid from Contact where id = :ctct.id].accountid];

pageReference nextPage = Page.enterServiceProjectPage;

nextPage.setRedirect(false);

return nextPage;

} else {

ContactNotListed = true;

return null;

}

}

}

public PageReference ReviewPage() {

pageReference nextPage = Page.enterServiceProjectReviewPage;

nextPage.setRedirect(false);

return nextPage;

}

public Opportunity setUpOpp() {

if (opp == null) {

opp = new Opportunity(name='autofill');

}

return opp;

}

public PageReference ReturnToEnterSPPage() {

pageReference nextPage = Page.enterServiceProjectPage;

nextPage.setRedirect(false);

return nextPage;

}

Anyone have any insight as to why the picklist dependency isn't working?  Oddly, at one point it seemed like it was working as we were testing (probably in a sandbox whereas this is in a production instance).

Thanks so much!

 
1 件の回答
  1. 2015年6月9日 17:32
    OK, I've resolved this.  After spending many hours reading up on this and knowing everything was set up as it should be, I found this:

    https://help.salesforce.com/apex/HTViewHelpDoc?id=pages_version_settings.htm.  It talks about versioning WITHIN VF pages.  I had not read about this feature until recently and had assumed any page would start with the instance API (which is 33).  I discovered that I could edit the version tied to the VF page directly, and it had been set at 15 - pre-dependent picklists.  Changed that to 33 and now it's working!
0/9000