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
bellzaonebellzaone 

getting piclist valuse according to the recordtype

i have 3 recordtype a,b,c

so i want to get the piclist value according to the recordtype.

what code should we write in apex controller to fulfill my work.................

AmitSahuAmitSahu
You don't need to write code for that.
Record type can have separate pick list values by configuration.
follow the user guide.

Regards,
J
cloudmaniacloudmania

in where do you want to display this picklist ?in VisualForce?

LoserKidLoserKid

Here is the code i used to some thing almost exactly the same. we have programs that correspond to our recordtypes so your not gonna be able to copy paste. but if you have any questions just ask.

 

public with sharing class ChooseCCCProgramController {
    
    public List<CCC_Program__c> programList;
    public List<RecordType> recordTypeList;
    public Profile userProfile;
    // public String rType {get; set;}
    public String selectedProgram;
    //public Case newCase;
    
    //public ChooseCCCProgramController()
    //{
    //   programList = [Select c.Name, c.Id  From CCC_Program__c c Where isActive__c = true Order BY c.Name];
    //    recordTypeList = [Select r.Name, r.Id From RecordType r];
    //    //newCase = new Case(); 
    //}
    
    public ChooseCCCProgramController(ApexPages.StandardController stdController) {
        
        recordTypeList = [Select Name, Id From RecordType Where SobjectType = 'Case'];
	    userProfile = [SELECT Name FROM Profile WHERE Id = :Userinfo.getProfileId()];
	    programList = [Select c.Name, c.Id  From CCC_Program__c c Where isActive__c = true Order BY c.Name];	
    }
     
    public PageReference goTo()
    {
    	String recordReference; // = '012V0000000CgcGIAS';
    	
    	if(userProfile.Name.contains('WWT Portal'))
	    {
	    	for (RecordType record : recordTypeList)
	        {
	            if(userProfile.Name.contains(record.Name))
	            {
	                recordReference = record.Id;
	            } 
	        } 
	    	Pagereference pageRef = new Pagereference('/500/e?retURL=%2F500%2Fo&RecordType=' + recordReference + '&nooverride=1'); // &ent=Case
	        pageRef.setRedirect(true);
	        return pageRef;
	    }
	    else
	    {
	    	return null;
	    }
    }
          
    public PageReference test() 
    {    
        String recordReference; // = '012V0000000CgcGIAS';
        
	    if(selectedProgram == 'Select Program')
        {
        	//ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Please make a selection before continuing');
        	//ApexPages.addMessage(msg);
        	return null;
        }
        else
        {
	        for (RecordType record : recordTypeList)
	        {
	            if(record.Name == selectedProgram)
	            {
	                recordReference = record.Id;
	                break;
	            }
	        }
	        Pagereference pageRef = new Pagereference('/500/e?retURL=%2F500%2Fo&RecordType=' + recordReference + '&nooverride=1'); // &ent=Case
	        pageRef.setRedirect(true);
	        return pageRef;
        }
    }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        
        options.add(new SelectOption('Select Program','Select Program'));

        for(CCC_Program__c program : programList)
        {
            String programName = program.Name;
            options.add(new SelectOption(programName, programName));    
        }
        return options;
    }
            
    public String getSelectedProgram() {
        return selectedProgram;
    }
            
    public void setSelectedProgram(String selectedProgram) {
        this.selectedProgram = selectedProgram;
    }
}