4

I am having two record type "Record Type 1" and "Record Type 2" on case object. In this two record type we are a having a picklist field call state__c. In Record Type 1 State__c values are "A,B,D" In Record Type 2 State__c values are "C,E,F".

I need to display this state__c picklist field value based on the record type in vf page. Kindly anyone give some idea to get the picklist filed values based on the record type in apex.

3 Answers 3

3

Kindly follow This Link. I've used this and its working now. Hope this would be useful.
Dont forget to add connection.js in includescript.

<apex:page >
 //use version according to org
    <script src="/soap/ajax/40.0/connection.js" type="text/javascript"></script>
    <script src="/soap/ajax/40.0/apex.js" type="text/javascript"></script>


    <script>
        sforce.connection.sessionId='{!GETSESSIONID()}';
        function init(){
           var result = sforce.connection.describeLayout('Opportunity'); //to do 
           console.log(result); //parse this object to find picklist values for each record type
        }
    </script>

    <body onload="init();">    
    </body>
</apex:page>
0
2

If picklist values for record type are properly set you just have to use <apex:inputField /> tag. Also why you use VF page for this?

1
  • Currently any VF page that has a custom controller or a standard controller referencing different multiple object (standard Account controller which also includes Contact picklists) will not respect the record type to filter the picklist. So <apex:inputField /> does not work in all cases.
    – maguy
    Commented Aug 31, 2016 at 14:30
2

Currently we can't access picklist values based on Recordtype in Apex code, please refer the idea https://success.salesforce.com/ideaView?id=08730000000gNpLAAU.

As @Artur mentioned <apex:inputField/> respects Recordtype settings for picklist i.e.picklist values are displayed in VF based on Recordtype assigned to logged in user.

You must log in to answer this question.

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