Incorrect ordering of custom metadata picklist fields in SOQL
Last updated 2020-03-02 ·Reference W-4986875 ·Reported By 20 users
Documentation shows that when using ORDER BY, picklist sorting is defined by the picklist sort determined during setup:
However with this issue the order that is observed is different. The picklist ordering is incorrect even when the picklist field is included in the SELECT results.
Similar known issue but not related to picklists: https://success.salesforce.com/issues_view?id=a1p3A0000001BreQAE
1. Create a CMT with a picklist field
2. Add several values to the picklist in non-alphabetical, non-numeric order
3. Create several CMT records, each with a unique picklist value
4. Execute the below SOQL query in developer console
SELECT Id, MyPicklist__c FROM MyType__mdt ORDER BY MyPicklist__c ASC NULLS LAST
5. Observe that the order of records returned may or may not match the order of the picklist values.
6. Use the Reorder button to change the order of the picklist values and save
7. Re-run the query
Expected: Order of records should have changed to the new order of the picklist
Actual: Records remain in same order as before
Manually sort the returned list in Apex after querying.
Reported By (20)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.