You need to sign in to do that
Don't have an account?
Dennis Antle
BULK CUSTOM METADATA soql where picklist = value
I have two metadata tables meta1, meta2 that have a Parent-child relationship labeled metarelate.
In meta2 the column Type__c is a Picklist.
Below are 2 different methods for querying the metadata tables.
Query 1
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c from meta1
WHERE metarelate__r.Active__c = true
and metarelate__r.Type__c = :metatype]){
//does not loop through any rows.
}
but If I do this
Query 2
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c, metarelate__r.Type__c from meta1
WHERE metarelate__r.Active__c = true]){
if(m.metarelate__r.Type__c = metatype){
//does loop through rows that have Type__c = 'type1'.
}
}
The query has alot of records, so I want to do it the first way, to save on CPU Time. But it will only work the second way, which eats up CPU Time. Why is it that in Query1 the where Clause on Type__c Column is not working. FYI it's a picklist.
In meta2 the column Type__c is a Picklist.
Below are 2 different methods for querying the metadata tables.
Query 1
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c from meta1
WHERE metarelate__r.Active__c = true
and metarelate__r.Type__c = :metatype]){
//does not loop through any rows.
}
but If I do this
Query 2
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c, metarelate__r.Type__c from meta1
WHERE metarelate__r.Active__c = true]){
if(m.metarelate__r.Type__c = metatype){
//does loop through rows that have Type__c = 'type1'.
}
}
The query has alot of records, so I want to do it the first way, to save on CPU Time. But it will only work the second way, which eats up CPU Time. Why is it that in Query1 the where Clause on Type__c Column is not working. FYI it's a picklist.
I tried your example and it is working the 'Query 1'. Are you sure that if it is going inside the 'if' sentence in the 'Query 2'.
If it is not, check your picklist values in the object edition if exists ' 'type1'. Moreover, check your meta1 records if you have at least one which it is linked with a meta2 record whose type is 'type1'.
Let me know if this helps you.
Thanks
I will use my actual soql in Developer Console – This works
When I add SFDCObjectType__c to the where clause = ‘PermissionSet’ it fails, even though in the first query, it’s clear that the ‘PermissionSet’ value exists for that field.
FYI : SFDCObjectType__c is a picklist
Add this to your query: If this doesn't return any record, the most likely is that it doesn't exists any record this query so you should create it.
Let me know if this solves your issue
Thanks
Records Exist with value 'PermissionSet', you can see them displayed in the first query.
Thanks
One thing I just noticed is that the relatationship column has the same name for the 'Related List Label' and the 'Child Relationship Name'.
Would that have anything to do with it?
Thanks