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

how to sort picklist value from custom settings and how to set default value

I stored all my picklis values in custom setting and i am accessing those values in my  controller like  /**for (ApplicationPicklist__c Application : ApplicationPicklist__c.getAll().values())
       options.add(new SelectOption(Application.Application__c ,Application.Name+' - '+Application.Application__c));
        return options;**/

do we have option to set any default value in apex code .and cn i sort the values alphabetically
Khan AnasKhan Anas (Salesforce Developers) 
Hi Divya,

Greetings to you!

Please try the below code:
List<ApplicationPicklist__c> ap=ApplicationPicklist__c.getAll().values();

for (ApplicationPicklist__c Application : ap) {
       options.add(new SelectOption(Application.Application__c ,Application.Name+' - '+Application.Application__c));

return options;

Please refer to the below link which might help you further.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas