You need to sign in to do that
Don't have an account?
Any way to obtain picklist values by record type?
Hello,
I'm familiar with the describeSObject call, which gives me the list of fields, and it gives me the list of picklist values for the picklist fields. But if the object has associated record types, I'd like to know which picklist values apply to a given record type. Within the salesforce UI, when I edit a record, the picklist fields for that record show only the picklist values applicable to that record's record type. How would I obtain that information via Apex calls? I know I can query the RecordType object to obtain the applicable record types for a given Salesforce object, but I'm unable to go beyond that.
Thanks in advance for any help.
Sridhar
You can't easily access this information, at least not in pure Apex Code. It is only exposed right now in the metadata API. I believe that Visualforce now respects Record Type settings for picklists. What's your use case?
sfdcfox - thanks for your response. The use case is Apsona for Salesforce, which provides a data management UI for Salesforce. It enables (among many other things) adding and editing data records into salesforce objects. In doing so, it needs to respect the salesforce data constraints, and show the user only those record types and picklist values that are accessible to the user. This is (of course) a non-issue for our Group Edition and Pro Edition users (since they don't have record types), but is significant for Enterprise Edition users.
It would be great if I could query an object via SOQL (like the RecordType object), and obtain the necessary info. Failing that, since you mention that it can be done with the metadata API, perhaps you can point me to some documentation I can chase up?
Thanks again,
Sridhar
http://apsona.com/salesforce
http://www.salesforce.com/us/developer/docs/api_meta/index.htm
Specifically, you'll need to take a look at "Using the Metadata API" for basics, and Reference > Metadata Types > CustomObject > RecordType (and Profile, and probably Picklist).
Apex Code would be difficult to use for this though, as I stated before, mostly because it's asynchronous by nature, so it could time out, etc. Performing JavaScript or using Flex or Java would be advisable to the Apex Code approach.
The Metadata API is documented as being primarily unusable in pure Apex Code.
bump for hope that winter 12 exposes this feature request via apex
id surely like to get pick list values for record type and make better visualforce pages
Here is a write up I did on how to pull these values without any development. Of course, it does require you have the eclipse IDE configured.
colemab you've got all values, but not for a partilular record type. The same can be done with describeSobject call, but you'll get all values.
So, has anyone found how to get this for a record-type?
@Rost. Y - here is a direct quote from my write up:
"When the file opens, scroll down and locate the <recordTypes> section that has the <fullName> you are looking for (Western in this case). Then Locate the <picklistValues> section that has the <picklist> with the field you want (State__c in this case).
There you will find a <values> section that will contain *just* the picklist values enabled for that record type."
Are you saying that this method no longer works? or do you need help getting to this point?
colemab, thanks
also, If someone needds to do this via API then you can get necessary data by describeLayout() call.
@Rost. Y No problem.
This can be achieved using a bit of javascript and the <apex:inputField> .... check out the post @ http://writeforce.blogspot.com/2012/11/the-trouble-with-picklists-visualforce.html
I cannot use javascript. I need to get it via API. In RoR application which works with SF viap SOAP API. Completely in backend.
Sridhar
http://apsona.com