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?

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

1 Answer 1

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
}
3
  • 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. Aug 5, 2019 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. Aug 5, 2019 at 20:25
  • The SFDC workaround doesn't pass the straight-face test - they should fix this.
    – cropredy
    Aug 5, 2019 at 22:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .