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
Siana DcruzSiana Dcruz 

How to rearrange the Picklist values

Hi All,
 
I am using the following code to get the picklist values from Time__c

public List<SelectOption> getTimeOptions()
    {
        List<SelectOption> options = new List<SelectOption>();
        List<String> Times = this.getDynamicPicklistValues('Intake__c', 'Time_c');
        for (String Time : Times)
        {
            options.add(new SelectOption(Time, Time));
        }

        return options;
    }

Time__c has following picklist values:
Time A
Time B
Time C
Time D

But I want the values to appear as:
Time B
Time D
Time C
Time A

Please suggest me how to do this?!!
 
Best Answer chosen by Siana Dcruz
SandhyaSandhya (Salesforce Developers) 
Hi Siana,

Please follow below steps

1.From the management settings for the picklist field’s object, go to Fields.
2.Click Edit next to the picklist you want to update.
3.Click Reorder.
4.Use the arrows to arrange the field in the proper sequence.
5.Select a default, if desired.
6.Check the box to alphabetize the entries for users on edit pages. The entries will always appear in alphabetical order, regardless of the user’s language.
7.Save your changes.

Please refer below links for management settings

https://help.salesforce.com/apex/HTViewHelpDoc?id=extend_click_find_objectmgmt.htm&language=en_US


Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya


 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi Siana,

Please follow below steps

1.From the management settings for the picklist field’s object, go to Fields.
2.Click Edit next to the picklist you want to update.
3.Click Reorder.
4.Use the arrows to arrange the field in the proper sequence.
5.Select a default, if desired.
6.Check the box to alphabetize the entries for users on edit pages. The entries will always appear in alphabetical order, regardless of the user’s language.
7.Save your changes.

Please refer below links for management settings

https://help.salesforce.com/apex/HTViewHelpDoc?id=extend_click_find_objectmgmt.htm&language=en_US


Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya


 
This was selected as the best answer
Siana DcruzSiana Dcruz
Hey Sandhya,
Is it possible for me to reorder the values in the code itself??
Vasani ParthVasani Parth
Hi Siana
You can rearrange eaisly..

Go to Picklist Field --> Click on "Reorder" Button --> Rearrange picklist values.

Please mark this as the Best Answer if this helps
SandhyaSandhya (Salesforce Developers) 
Hi Siana Dcruz,

If you are trying to reorder based on any condition, iI mean any custom sort order then I suggest you refer below link which has detailed explaination on sorting the List.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_list_sorting_sobject.htm

Hope this helps you.

Thanks and Regards
sandhya