Is there a workaround to handle order-by in cross-Object metadata relationships?

So Here is the querry.

SELECT Id FROM Child__mdt ORDER BY Parent__r.Order__c ASC

where Parent and Child are the Custom Metadata types.

The error I get.

UNKNOWN ERROR: INVALID_OPERATION: The requested operation is not yet supported by this SObject storage type, contact salesforce.com support for more information.


As the error says, you can't sort via SOQL. The only "workaround" is the typical "implement a wrapper class that implements Comparable." For example, you could implement a variant of this class, or this class, or even just implementing your own sorting algorithm. Hopefully this will be implemented in a future release, but I couldn't find any Known Issues or Ideas related to that (please feel free to edit it in here if you find/submit something).

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.