You need to sign in to do that
Don't have an account?
Dynamic Picklist Value base on Record Type
Hello, I have a requirements to populate a picklist base on the values in the string field All__c. For example.
I have a picklist Animals__c which have data of "Dog, Mouse, Cats, Rats, Birds".
in Record Type 1 Animals__c values are "Mouse, Rats"
in Record Type 2 Animals__c values are "Dog, Cats, Birds"
In Record Type 1:
If the field All__c has the value of "2" the Animal__c in record type 1 = "Mouse, Rats"
If the field All__c has the value of "3" the Animal__c in record type 2 = "Dog, Cats, Birds"
If the field All__c has the value of "2,3" the Animal__c in record type 5 = "Mouse, Rats,Dog, Cats, Birds"
Any help will be very much appreciated.
Thanks!
Hi,
I think you either want to use a dependent picklist based upon All__c or set the object to use record types and then create a normal picklist where the values are different depending on the record type.
As you already have the field All__c I would recommend making the dependent picklist that uses that field's value. However, record types in Salesforce can also allow you to do this and control other items such as page layout. It took me a moment to reaise when you said record type in your post you didn't actually mean record types in salesforce.
Confusing, but hopefully the dependent picklist solution can help you out :-)
Paul
Hi Paul,
Thanks for the reply. But what I exactly need is to get the values of a picklist base on the Record Type.
I need to retrieved the values of picklist Animal__c from record type 1 and record type 2 if the value in string All__c is "2,3".
So to clarify (then we can definitely help you)
You have an object which has 2 record types, 1 and 2.
These record types control the values available in a picklist. You want these value to then be determined based upon a String field All__c.
As it is a string field, dependent picklists are out and you already have your record type determined. I believe this is going to require either workflow or a trigger in order to populate your field when the record is created. I don't think this is going to really be possible without code.
My solution (open to a better suggestion here) is that you have a page which has a VF selectlist on it and you determine the available select options in your controller using the record type of the record you have (or have been passed through the standard controller) and then display the correct list of options based upon that and the value of your All__c field. You can still have the picklist and the fields defined on the custom object and then use the describe information to retrieve the available options. Maybe store the configuration rules in a custom setting as they are likely to be write once read often and you could then manage this all through config in the future.
Does that make sense? If not let me know.
Paul
Paul
I guess you are getting me wrong. Lets forget about the All__c fields. Lets put it this way:
For example, I have the record types 1 & 2 & 3 and it controls the values available in picklist.
Picklist Values: Dog, Cat , Birds, Mouse, Rats, Elephant
Record Type 1
Picklist Values : Dog, Cat , Birds
Record Type 2
Picklist Values : Mouse, Rats
Record Type 3
Picklist Values : Elephant
What I wanted to have is to get the value of picklist base on the record type. So,
If I wanted to get the values of picklist in record type 3, I want to have this result:
Output = Elephant
If I wanted to get the values of picklist in record type 1 & 3, I want to have this result:
Output = Dog, Cat , Birds,Mouse, Rats
If I wanted to get the values of picklist in record type 1 & 2 & 3, I want to have this result:
Output = Dog, Cat , Birds,Elephant
BTW, thanks for replying to my queries. :)
Okay, think I understand, but I am afraid to tell you that this is not currently possible through Apex, only through the metadata API (see http://boards.developerforce.com/t5/Apex-Code-Development/Any-way-to-obtain-picklist-values-by-record-type/td-p/287563).
Unless you do some clever custom coding like I mentioned before, or this has been added in winter 12 without me noticing then it's not possible in plain apex (even using describe information).
Sorry :-( Let me know if you have any other qeries or qestions though.
Paul
Thanks Paul. I really need this features for SF. Btw, why cant I access the link you post. Thanks!
No problem, glad I could sort of help.
I am getting an error from the BB when I try to access it so must be something in the background going on.
Paul
Hi ,
We can do what you need but it does not work for the dependent picklist which controlled by another picklist.
Use system log to execute the script.
List<String> options = PicklistDescriber.describe('ObjectName', 'Record Nype Name', 'Field Name');
system.debug('options--'+options);