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

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>
| improve this answer | |
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?

| improve this answer | |
  • 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 Aug 31 '16 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.