8

I'm getting some weird behavior with a SOQL WHERE clause on a Custom Metadata Type query:

SELECT  Id, Label, DeveloperName, Version__c, Content__c 
FROM My_Text_Content__mdt WHERE Version__c = '2020' 

The resulting dataset has about the right number of records, but it doesn't contain all the records where Version__c is "2020", and it contains some records whose Version__c is something other than "2020".

enter image description here

Thoughts? Ideas?

  • 2
    Is it picklist feild? – Pranay Jaiswal Aug 5 at 19:19
  • Good question -- no. It's Text(20). – Matthew Souther Aug 5 at 19:24
  • 2
    Is it sandbox, prod or scratch org? – Pranay Jaiswal Aug 5 at 19:27
  • It's a sandbox. – Matthew Souther Aug 5 at 19:28
  • 1
    Can you try same query in prod? I think I somewhat saw similar in sandbox but it worked in prod. – Pranay Jaiswal Aug 5 at 19:29
5

Since there are more than 200 results, it could be a variation of this known issue.

Try executing it as a script instead of a query:

List<My_Text_Content__mdt> myTextContents = [Select Id, Label, DeveloperName, Version__c, Content__c 
    FROM My_Text_Content__mdt WHERE Version__c = '2020' 
    ORDER BY Version__c];

for(My_Text_Content__mdt myTextContent: myTextContents){
    //Inspect results here
}
  • Thanks! Same result, though, per System.debug. :-( I actually saw that Known Issue in my original search, but ruled it out since the workaround looks the same as what I'm currently doing. – Matthew Souther Aug 5 at 19:55
  • Upon further testing on other custom metadata types in our orgs, the issue seems to crop up when the expected result set is over 200 rows. So although the script approach is not providing the hoped-for solution (and the official Salesforce workaround is useless from my perspective), I do agree these could be related issues. – Matthew Souther Aug 5 at 20:25
  • The SFDC workaround doesn't pass the straight-face test - they should fix this. – cropredy Aug 5 at 22:54

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.