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([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...

  • Is fetching by the developer name (i.e. getRecordTypeInfosByName()) not an option? If you truly do need the label, would RecordTypeInfo.getName() not work after fetching by developerName?
    – Derek F
    Sep 27 '18 at 12:44
  • 2
    Since the customers can also set the names, it would result in the same issue. I don't need the label in general, mostly I just need the record type id. So customers could override my record types by defining their own, that feels so wrong, since developer names should always be unique, so we can rely on them..
    – Basti
    Sep 27 '18 at 13:39
  • 1
    I just did a lot of digging and couldn't come up with anything either. Looks like you found yourself a system bug. It's not on the known issues list yet. Time for your 10 minutes of fame! ;) Sep 29 '18 at 2:39
  • 1
    also: if there is a custom record type named "Master" - getRecordTypeInfosByName will return the system "Master" not the custom one. Query will return only the custom one. Mar 4 '19 at 15:53
  • 1
    I raised this on the partner forums when I too discovered this gap in the API.
    – Phil W
    Jun 28 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.