function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cvuyyurucvuyyuru 

Dependent picklists in VF page.

Guys,

 

I am presently working on Sites.

 

I have 3 picklist fields on Product Object. Let them be as A, B,C.

 

B is Dependednt on A, and C is dependent on B. 

 

I cannot display picklists fields of Product sobject in Sites, as I have only Read permission over that object.

 

So, I decided to display picklist values by calling describe method for field name of every object.

 

I am using

 

 Schema.SObjectField F1 =product2.A;

 List<Schema.PicklistEntry>pv=f1.getdescribe().getpicklistvalues(); 

 

In the same I can get the values of 3 picklists.

But, How can I get the dependencies that exist among them.

 

 

 

 

Thanks,

Charan

MRosiMRosi

Dear Charan,

 

These two articles describe rolling your own dependent picklists.

 

Force Tips : Creating A Dependent Picklist

http://force-tips.blogspot.com/2010/02/creating-dependent-picklist.html

 

Discover the Advanced Capabilities of Visualforce - Part 2

http://wiki.developerforce.com/index.php/Extended_Functionality_of_Visualforce_-_Part_2

 

However I see you are asking how to get the controlling item from schema. This is not a complete answer, but check these out. Perhaps the validFor field is the answer?

 

"In the Field object associated with the DescribeSObjectResult, the picklistValues field contains an array of PicklistEntry properties. Each PicklistEntry can contain any one of the following string values. "

  validFor  /  byte[]  /  A set of bits where each bit indicates a controlling value for which this PicklistEntry is valid. See About Dependent Picklists.

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describesobjects_describesobjectresult.htm#i1427932

http://www.salesforce.com/us/developer/docs/api/Content/field_types.htm#i1435709

 

Hope this helps,

 

Matt