Our product comes with a couple objects including RecordTypes.
In our customer org I'm adding some RecordTypes and experienced, that I can give them names that the packaged types already have.
So now I have two RecodTypes with the developer name "BuggyRecordType", they only differ in there NamspacePrefix
.
Thats fine so far.
But when I try to use the new getRecordTypeInfosByDeveloperName()
method, it only returns my new Record Type and the other one is just skipped. This doesn't feel right to me.
The recodTypeInfoByDevName
map in my example for sure only contains it once, since the key would be the same. Another issue here is, that I don't even see the namespace prefix in the RecordTypeInfo object.
Map<String, RecordTypeInfo> recodTypeInfoByDevName = SObjectType.Account.getRecordTypeInfosByDeveloperName();
for(String devName : recodTypeInfoByDevName.keySet()) {
System.debug(recodTypeInfoByDevName.get(devName));
System.debug([SELECT DeveloperName, NamespacePrefix FROM RecordType WHERE DeveloperName = :devName]);
}
Results in:
Schema.RecordTypeInfo[getDeveloperName=BuggyRecordType;getName=Buggy Record Type;getRecordTypeId=012C0000000CGtyIAG....]
(RecordType:{DeveloperName=BuggyRecordType, NamespacePrefix=PKG, Id=012C0000000IIIaIII}, RecordType:{DeveloperName=BuggyRecordType, NamespacePrefix=NEW, Id=012C0000000CGtyIAG}
Is there any way to avoid SOQL here? If not it feels like the whole feature is useless, since you never know, what the customer does...
getRecordTypeInfosByName()
) not an option? If you truly do need the label, wouldRecordTypeInfo.getName()
not work after fetching by developerName?