You need to sign in to do that
Don't have an account?
IKZ
custom settings in alphabetical order
i've added sort() to my code, but values from the custom setting are still listed in random order, what am i missing?
public List<SelectOption> getAvailableDocumentTypes() { List<SelectOption> options = new List<SelectOption>(); options.sort(); for (Available_Document_Types__c doc_type : Available_Document_Types__c.getall().values()) { options.add(new SelectOption(doc_type.Value__c, doc_type.Name)); } return options; }
Greetings to you!
You are using sort() on a blank list. You need to use sort() after you are adding the values to the options list.
Use this:
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
All Answers
public List<SelectOption> getAvailableDocumentTypes() {
List<SelectOption> options = new List<SelectOption>();
for (Available_Document_Types__c doc_type : Available_Document_Types__c.getall().values()) {
options.add(new SelectOption(doc_type.Value__c, doc_type.Name));
}
options.sort();
return options;
}
Please mark the answer as best answer if it resolves your issue.
Thanks.
Greetings to you!
You are using sort() on a blank list. You need to use sort() after you are adding the values to the options list.
Use this:
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