Label value appears in DeveloperName field of Custom Metadata Types query when run as Community User but not with Admin
Custom Objects , Developer Console , Communities
Last updated 2022-02-15 ·Reference W-7217580 ·Reported By 13 users
In Review
Summary
DeveloperName field is returning label instead of API name (Developer Name) for the community user when it is in relationship query.
Note: The issue is not reproducible to System admin, as mentioned it is only to community users.
Repro
> Create a Parent MDT
> Create a Child MDT and added parent MDT as metadata relationship field
> Populate manage records for both Child and Parent MDT
> There is some discrepancy when this SOQL executed from System.runAs() for admin and community users - [select id, Label, DeveloperName, HarshCase__ParentMDT__r.DeveloperName from HarshCase__ChildMDT__mdt]
System.runAs(u)
{
List<HarshCase__ChildMDT__mdt> t=[select id, Label, DeveloperName, HarshCase__ParentMDT__r.DeveloperName from HarshCase__ChildMDT__mdt];
System.debug('t::'+t);
for( HarshCase__ChildMDT__mdt i :t){
System.debug('i---'+ i.HarshCase__ParentMDT__r.DeveloperName);
System.debug('i---'+ i);
}
}
> For a community user:
14:40:35:017 SOQL_EXECUTE_BEGIN [7]|Aggregations:0|SELECT Id FROM User WHERE Id = '0056F00000BtUIv' LIMIT 1
14:40:35:048 USER_DEBUG [30]|DEBUG|i---ParentLabel
> For a system admin user:
14:52:57:018 SOQL_EXECUTE_BEGIN [8]|Aggregations:0|SELECT Id FROM User WHERE Id = '0056F00000AMhFb' LIMIT 1
14:52:57:053 USER_DEBUG [30]|DEBUG|i---ParentDeveloperName
Workaround
workaround by adding ParentMDT__r.QualifiedApiName to the select clause to make ParentMDT__r.DeveloperName return the developer name for community users.
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.