0

My vf page(custom controller vf page) has picklist field in it and I am showing it with apex:inputField tag, as per the salesforce documentation, apex:inputField should show record type specific default picklist value on page load, but my vf page is showing -None- value on page load, its not showing record type specific default picklist value. I have given snippet of my vf page code, please let me know what I am missing here.

<apex:page controller="CustomControllerClass">
<apex:form >
    <apex:inputField value="{!leadRecord.picklist_field__c}"/>
</apex:form></apex:page>

Please note, my vf page is custom controller vf page and the API version of page is 58.

1 Answer 1

1

I tested this, and it works as expected. Make sure you're setting the record type Id.

Here's my version:

public class CustomControllerClass {
    public account record { get; set; }
    public CustomControllerClass() {
        Id recordTypeId = sObjectType.Account.getRecordTypeInfosByDeveloperName()
            .get('Demo').getRecordTypeId();
        record = new Account(RecordTypeId=recordTypeId);
    }
}
<apex:page controller="CustomControllerClass">
    <apex:form>
        <apex:inputField value="{!record.type}" />
    </apex:form>
</apex:page>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .