You need to sign in to do that
Don't have an account?

Filter record type selection
Hi,
I'm trying to create a visualforce page which filters the standard Opportunity record type selection page based on the related Account record type. I'm getting this error upon saving my VF:
Error: Unknown property 'AccountStandardController.recTypeID'
Here's my code:
VF:
<apex:page standardController="Account">
<apex:form >
<apex:selectList value="{!recTypeID}" size="1">
<apex:selectOptions value="{!myOptions}"></apex:selectOptions>
</apex:selectList>
<apex:commandButton value="Next" Action="{!continue}"/>
</apex:form>
</apex:page>
Controller:
public class myController {
public List<SelectOption> opts {get;set;}
private String oType {get;set;}
public Id recTypeId {get;set;}
myController(){
oType = 'Opportunity';
}
public List<SelectOption> myOptions() {
opts = new List<SelectOption>();
opts.add(new SelectOption('','--Please Select Record Type --'));
for(RecordType rts : [Select Id, DeveloperName, Name From RecordType Where SObjectType = 'Opportunity']) {
opts.add(new SelectOption(rts.id,rts.name));
}
Map<String,List<String>> mapping = new Map<String,List<String>>();
mapping.put('Small_Medium_Sized_Business', new List<String>{'Defined_Benefit_Retirement','Defined_Contribution_Retirement'});
return opts;
}
}
I'm trying to create a visualforce page which filters the standard Opportunity record type selection page based on the related Account record type. I'm getting this error upon saving my VF:
Error: Unknown property 'AccountStandardController.recTypeID'
Here's my code:
VF:
<apex:page standardController="Account">
<apex:form >
<apex:selectList value="{!recTypeID}" size="1">
<apex:selectOptions value="{!myOptions}"></apex:selectOptions>
</apex:selectList>
<apex:commandButton value="Next" Action="{!continue}"/>
</apex:form>
</apex:page>
Controller:
public class myController {
public List<SelectOption> opts {get;set;}
private String oType {get;set;}
public Id recTypeId {get;set;}
myController(){
oType = 'Opportunity';
}
public List<SelectOption> myOptions() {
opts = new List<SelectOption>();
opts.add(new SelectOption('','--Please Select Record Type --'));
for(RecordType rts : [Select Id, DeveloperName, Name From RecordType Where SObjectType = 'Opportunity']) {
opts.add(new SelectOption(rts.id,rts.name));
}
Map<String,List<String>> mapping = new Map<String,List<String>>();
mapping.put('Small_Medium_Sized_Business', new List<String>{'Defined_Benefit_Retirement','Defined_Contribution_Retirement'});
return opts;
}
}
Great question. And even simplier solution. Right now, your VF page has a single controller, namely the standard Account. Your Custom Controller needs to be added into the mix.
Within the Page tag of the VF page, make it look like:
<pre>
<apex:page standardController="Account" extensions="myController">
</pre>
Once you do this though, your myController constructor will have to include a single argument - the Standard Controller.
So, maybe your Apex Controller Constructor look like this:
<pre>
myController(ApexPages.StandardController stdController){
oType = 'Opportunity';
}
</pre>