You need to sign in to do that
Don't have an account?
Anshul Kapoor 13
How to get the pick list values dynamically as per record type
Hi,
How to get the pick list values dynamically using record type-
Below is the code-
vf Page-
<apex:selectList id="countries" value="{!Office_Location__c.Country__c}"
size="1" required="true">
<apex:selectOptions value="{!countries}"/>
</apex:selectList>
public List<SelectOption> getCountries()
{
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult =
OfficeLocation__c.Country__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}
I have 2 record types - Scanback & AutoBill & field country having different values as per record Type.
How to get the pick list values dynamically using record type-
Below is the code-
vf Page-
<apex:selectList id="countries" value="{!Office_Location__c.Country__c}"
size="1" required="true">
<apex:selectOptions value="{!countries}"/>
</apex:selectList>
public List<SelectOption> getCountries()
{
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult =
OfficeLocation__c.Country__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}
I have 2 record types - Scanback & AutoBill & field country having different values as per record Type.
Currently we can't access picklist values based on Recordtype in Apex code, please refer the idea
https://success.salesforce.com/ideaView?id=08730000000gNpLAAU.
If picklist values for record type are properly set you just have to use <apex:inputField /> tag.
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
sfdcmonkey.com
All Answers
Currently we can't access picklist values based on Recordtype in Apex code, please refer the idea
https://success.salesforce.com/ideaView?id=08730000000gNpLAAU.
If picklist values for record type are properly set you just have to use <apex:inputField /> tag.
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks
sfdcmonkey.com
Ur answer is the best Answer :)