function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andy Kallio 7Andy Kallio 7 

SOQL on custom metadata when filtering for picklist?

Hello Friends.
I ran into problems querying a custom metadata object. I found the query was not working as expected when filtering on a picklist field. To test I then created a text field and put the same value as the picklist field. The query on the text field works.  Just wondering anybody else has ran into this. 


picklist field: Record_Type__c
text field: Record_Type2__c

non-working query:
select Id,
                      MasterLabel,
                      VF_Display_Name__c,
                      Component_Name__c,
                      PDF_Page_Factory__r.VF_Page__c,
                    PDF_Page_Factory__r.Object__c,
                    PDF_Page_Factory__r.Record_Type__c 
               from PDF_Component_Factory__mdt
             where  PDF_Page_Factory__r.Object__c = 'Quote'
and PDF_Page_Factory__r.Record_Type__c = 'Research'

working query:
select Id,
                      MasterLabel,
                      VF_Display_Name__c,
                   	 Component_Name__c,
                      PDF_Page_Factory__r.VF_Page__c,
                     PDF_Page_Factory__r.Object__c,
                     PDF_Page_Factory__r.Record_Type__c 
               from PDF_Component_Factory__mdt
             where  PDF_Page_Factory__r.Object__c = 'Quote'
and PDF_Page_Factory__r.Record_Type2__c = 'Research'

 
Best Answer chosen by Andy Kallio 7
Khan AnasKhan Anas (Salesforce Developers) 

Hi Andy,

Greetings to you!

An internal bug has been raised for this issue (W-5709686). For now, there is no workaround. Will keep you posted once it gets fixed.

ISSUE:
> The implementation consists of 2 custom metadata types "Master" & "Slave". The master has a picklist field and a text field.
> These 2 metadata types are associated using the custom metadata relationship.
> When we try to query the custom metadata using relationship and if the "WHERE" clause refers the Master's picklist value - it fails to return results.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas