2

Cannot sort on a soql-request in a custom meta data type. When i perform SELECT .. FROM x__mdt WHERE ... ORDER BY x. Then field x cannot be numeric to get a correct order. Change it to a string-field ordering works ok. Playing with ASC/DESC makes no difference!

  • 2
    Is there a question here? – Keith C Oct 27 '16 at 12:30
3

You can only order by a field that's in the SELECT clause of the query for custom metadata types -- see p.3 of the Custom Metadata Types Implementation Guide for more information on query limitations.

  • Thanks I missed that one 'SELECT .. FROM x__mdt WHERE ... ORDER BY x'. must be 'SELECT x FROM x__mdt WHERE ... ORDER BY x'. – WvB Oct 28 '16 at 7:32
0

See the known issue Custom Metadata Type not being sorted as expected.

Sorting order not being used in SOQL with Custom Metadata Type when sort field is not in column queried. This result in the order not being returned properly with Flows, API, Apex, and any functionality which would use a SOQL query for Custom Metadata Type.

...

Workaround

You can only use ORDER BY when the ordered field is a selected field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.