Loading

Salesforce List View Does Not Sort Text Fields in Alphabetical or Numerical Order

Fecha de publicación: Oct 13, 2022
Descripción

In Salesforce, list views may not sort in the order you expect. This most often occurs when sorting using text fields that contain numerical values, or when sorting picklist fields that include inactive values. This behavior also applies when using the "Set by multiple columns" sort feature.
Example:

  • 2080 Century Park East, Suite # 1804
  • 2080 Century Park East, Suite # 203

Issue: Suite 1804 should sort after Suite 203, but instead appears before it in the list view. Additionally, encrypted fields cannot be sorted in a list view.

Solución

List views in Salesforce sort text fields character-by-character rather than numerically, which can cause unexpected ordering. For example: 2080 Century Park East, Suite # 1804 comes before 2080 Century Park East, Suite # 203 because it sees that the "1" in "1804" comes before the "2" in "203". It does not evaluate "1804" as a whole number. To get correct numerical sorting, use Number field types instead of Text fields. For picklist fields, inactive values must be alphabetized alongside active values to sort correctly.


If the sorting field is a text field containing numbers:
The recommended workaround is to store numerical values in fields of type Number instead of Text. When a Number field is sorted, Salesforce evaluates the value as a whole number. In this case, "203" correctly appears before "1804".

 

If the sorting field is a picklist:
Inactive picklist values may be causing unexpected sort behavior. To fix this:

  1. In Lightning Experience: Click the Gear Icon | Setup | Object Manager | Object | Fields & Relationships. In Salesforce Classic: Your Name | Setup | Customize | Object | Fields.
  2. Click the name of the desired picklist field.
  3. Click the Reorder button.
  4. Select the Display values alphabetically, not in the order entered checkbox.

The sort will now work with both inactive and active values in your list view.

Additional Resources

 

Número del artículo de conocimiento

000385188

 
Cargando
Salesforce Help | Article