+ Start a Discussion
murtazaalimirmurtazaalimir 

Object Record Type Instance Picklist values in visual force page

Can any one helps me . 
Scenario i have student object having 2 record types having picklist name : 'Group'
for example 
Record type 1 have these picklist values :
Group 1
Group 2
Record type 2 have these piclist values :
Group 3

Group 4

Group 5
these are showing fine if we just use the standard layout .
the problem is that on visual force page i am only creating the students record of record type 1 so i just want to display the picklist in visual force having the exact same values as they are showing in layout..
i.e
page :
<apex:inputField value="{!instance.Group__c}"/>
controller:
student__c instance = new student__c();


i know that i will achieve it by custom picklist but i wnat to know the standard method if exists..
thanks in advance :-)

Best Answer chosen by Admin (Salesforce Developers) 
murtazaalimirmurtazaalimir

thanks for all your replies
i have found a solution. sharing with you guys
class:
public student__c instance {get;set;}
constructor
{
  instance = new student__c();

  ID rtId = [SELECT Id FROM RecordType WHERE sObjectType='student__c' AND Name='Group 2'].Id;

  instance = (student__c)student__c.sObjectType.newSObject(rtId, true);
}
visual force page :
<apex:inputField value="{!instance.Group__c"} />
now this input field is displaying the particular picklist values as are in group 2 record type 

All Answers

Ranu JainRanu Jain

Hi,

 

Its wark fine natively. Please check version of your class and page. Issue may arise due to version. 

 

murtazaalimirmurtazaalimir

thanks for all your replies
i have found a solution. sharing with you guys
class:
public student__c instance {get;set;}
constructor
{
  instance = new student__c();

  ID rtId = [SELECT Id FROM RecordType WHERE sObjectType='student__c' AND Name='Group 2'].Id;

  instance = (student__c)student__c.sObjectType.newSObject(rtId, true);
}
visual force page :
<apex:inputField value="{!instance.Group__c"} />
now this input field is displaying the particular picklist values as are in group 2 record type 

This was selected as the best answer
Manisha PatilManisha Patil
Hi,

How do I save these values to a field ?