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
PRIYAN NEERUDUPRIYAN NEERUDU 

m unable to get reord types as picklist values...can anyone help solve this issue

<apex:page controller="getrecordtype">
<apex:form >
YEAR<apex:selectList Size="1">
<apex:selectOptions value="{!items}"></apex:selectOptions>
</apex:selectList>
<apex:selectList >
<apex:selectOption value="{!RecordTypeSelectedId}"></apex:selectOption>
 </apex:selectList>
 </apex:form>
</apex:page>
------------------------------------------------------------------------------------------------------------
public with sharing class getrecordtype {

    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        


public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
            
 
}
Best Answer chosen by PRIYAN NEERUDU
Magesh Mani YadavMagesh Mani Yadav
Hi Priyan

The updated class and the VF page. Hope this helps you
<apex:page controller="getrecordtype">
<apex:form >
YEAR<apex:selectList Size="1">
<apex:selectOptions value="{!items}"></apex:selectOptions>
</apex:selectList>
<apex:selectList  >
<apex:selectOptions value="{!RecordTypeItems}"></apex:selectOptions>
 </apex:selectList>
 </apex:form>
</apex:page>
 
public with sharing class getrecordtype {
	List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    
    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    //List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        
}
    
    public List<SelectOption> getRecordTypeItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(RecordType r : rtList){
           options.add(new SelectOption(''+r.ID,r.name)); 
        }
        return options;
    }
    

public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
            
 
}

 

All Answers

Magesh Mani YadavMagesh Mani Yadav
Hi Priyan

The updated class and the VF page. Hope this helps you
<apex:page controller="getrecordtype">
<apex:form >
YEAR<apex:selectList Size="1">
<apex:selectOptions value="{!items}"></apex:selectOptions>
</apex:selectList>
<apex:selectList  >
<apex:selectOptions value="{!RecordTypeItems}"></apex:selectOptions>
 </apex:selectList>
 </apex:form>
</apex:page>
 
public with sharing class getrecordtype {
	List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    
    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    //List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        
}
    
    public List<SelectOption> getRecordTypeItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(RecordType r : rtList){
           options.add(new SelectOption(''+r.ID,r.name)); 
        }
        return options;
    }
    

public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
            
 
}

 
This was selected as the best answer
PRIYAN NEERUDUPRIYAN NEERUDU
hi thnk you it was helpfull...but one more requirement...........on change of record type in picklist i  want to render getamount method where ill fetch aggretaefields of contact object and display in vf page...can u plz suggest whr m gng wrng in below code.

<apex:page controller="getrecordtype">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
YEAR
<apex:selectList Size="1">
<apex:selectOptions value="{!items}">
</apex:selectOptions>
 </apex:selectList>
 </apex:pageBlockSectionItem>
 <apex:pageBlockSectionItem >
RECORD TYPE
<apex:selectList size="1" >
<apex:selectOptions value="{!RecordTypeItems}">
</apex:selectOptions>
<apex:actionSupport event="onchnage" rendered="amountfields"/>
 </apex:selectList>
 </apex:pageBlockSectionItem>
 
<apex:pageBlockSectionItem id="amountfields">
<apex:repeat value="{!getamount}"></apex:repeat>
</apex:pageBlockSectionItem>

 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
</apex:page>
----------------------------------------------------
public with sharing class getrecordtype {
map<id,AggregateResult> clist1 = new map<id,AggregateResult>();
   public string selectedrecordtype{get;set;}
    List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    
    public String getRecordTypeSelectedId(){
  String recordTypeName;
    String rtId;
    //List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'contact']);
    for(RecordType rt : rtList) {
        if(rt.Name == recordTypeName) {
             rtId = rt.Id;
        }
    }
    return rtId;        
}
    
    public List<SelectOption> getRecordTypeItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(RecordType r : rtList){
           options.add(new SelectOption(''+r.ID,r.name)); 
        }
        return options;
    }
    

public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('2014','2014'));
            options.add(new SelectOption('2015','2015'));
            options.add(new SelectOption('2016','2016'));
            return options;
        }
          
           public map<id,AggregateResult> getGetamount() {
           
         for(AggregateResult ar :[select sum(PAID_AMOUNT__c) s ,sum(BALANCE_AMOUNT__c) a ,sum(amount__c) c,accountid  from contact where  Recordtype = 'selectedrecordtype' group by accountid] ){
            clist1.put((Id)ar.get('accountid'),ar);
        }
        return clist1;
    }

            
 
}


 
Magesh Mani YadavMagesh Mani Yadav
Hi Priyan,

You were missing some syntax
[select sum(PAID_AMOUNT__c) s ,sum(BALANCE_AMOUNT__c) a ,sum(amount__c) c,accountid  from contact where  RecordtypeId = :selectedrecordtype group by accountid]

 
Magesh Mani YadavMagesh Mani Yadav
mark it solved if the initial query was solved