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

Getting picklist values?

Can someone show me how to retrieve the Task.subject picklist values in s-control, please?


Message Edited by okaylah52 on 08-19-2008 03:38 AM
Perhaps this will help you get started ..?

I'm not certain that 'Subject' shouldn't be 'Subject__c', and there may be a more elegant/concise way to go about it.  

function getSubjectPicklist() {
    var describeResult = sforce.connection.describeSObject("Tasks");
    var rlist;
    i = 0;
    do {
         var field = describeResult.fields[i++];
         if ( == Subject) {
             rlist = field.picklistValues;
    } while rlist == null && i < describeResult.fields.length);


If what you are after is creating an input element that represents the org's picklist options then the Visualforce version would be:
<apex:inputField value="{!task.subject}"/>

If you are doing something else with the values then you can use an Apex controller or controller extension to get the same describe information.

Calling describe inside of a browser can be dangerous if you start doing a lot of it or if you have a couple objects with 100's of fields or lots of picklists having lots of picklist values.  Be careful how far you go with describe in javascript or just switch to Visualforce and don't worry about it ;-)

Here's a recorded webinar that speaks to additional benefits of Visualforce over scontrols.

If after all of this you are still unconvinced that Visualforce is a better solution then I would at least advise that you create an Apex webservice to give you what you need and nothing more in your javascript. DescribeSObjectResult can be enormous (getting bigger with each release in fact) and you have no control over the granularity of what is returned - something an Apex webservice could give you. Please do take the time to evaluate Visualforce before taking this approach.

I realize the S-Controls are deprecated in favor of VisualForce; speaking for myself, a great breakout/takeaway from Dreamforce would(will?) be side-by-side examples of S-Controls and their same-function counterparts in VisualForce/Apex. 

I have the Cookbook, and a great companion volume/appendix would be to compare "Here is an example of an S-Control that copies values from a Opportunity and updated the associated Account, and here is the same functionality in VisualForce."  Also how to encapsulate a function from an S-Control into an Apex class and the associated INCLUDE syntax to include it in the new VisualForce class/functionality.

I would be more than happy to use the latest methods to get my work done, but I deal with legacy code, and use it as example code to develop new functionality for the same or different clients.  I can work from examples (usually :) ), but I find it difficult to get started in a new language with a Rosetta Stone indicating the transition.

I will search Ideas to see if this is already in there - I think it would be very useful for those of us who are not as accomplished in the Apex world as we might like to be.
Great suggestion!  Please do add this as an idea for a session as it will help me make the case :)

As for comparisions between scontrols and Visualforce pages the webinar I referenced in my previous response covers an exact scenario like this with the Visualforce solution fully documented here:

(sorry that's not an actual hyperlink - the editor will not enable it without replacing my text with the word "Link:")

Which compares use of Visualforce  against an scontrol to perform the exact same function.  You can get the original scontrol from the appexchange directory listing here.

Please do create the idea and I would appreciate it if you could post a link to it here so others reading this can promote the idea.

Thanks Andrew, thanks "finalist".

I finally developed the page I wanted by replacing the whole Account detail page with my Visualforce page + my custom buttons and list.

I found the following blog is very useful and educating. It provides the solution similar to "finalist" suggested except it generalizes the function to retrieve picklist values. Here is the link from Interactive Ties. The blog also shows how to create calendar picker, dynamic picklist and other useful tips.
Thanks for the encouragement (and sorry I didn't take the time to view the webinar :()

Here's the address and link to my Ideas post: