Use Name vs DeveloperName for RecordType?

What is best practice for working with RecordType in Apex (using DeveloperName)? Why should I use SOQL with DeveloperName if I can do it without query using regular name:



[SELECT Id FROM RecordType WHERE DeveloperName ='xxx'].Id;

Both Name and DeveloperName are changed when editing Name.


Actually, that is not quite true. Name is the field that the user sees when they choose it in the screen (or on the Page Layout). Developer Name is the API name for the record.

This is very similar to the way the Label and the API Name work for fields and object.

Because of this, it is best practice to always use Developer Name, since it is less likely to change (and it is unique in the object). As a dev, you can easily rename the Name to adjust to changing business requirements, but need not rename the Developer Name and leave your code working just fine.

Per the Docs:

Developer Name

Required. The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. In managed packages, this field prevents naming conflicts on package installations. With this field, a developer can change the object’s name in a managed package and the changes are reflected in a subscriber’s organization. Label is Record Type Name.


Required. Label of the record type in the user interface. Limit: 80 characters. Label is Record Type Label.

You can read the entire explanation here, in SFDC documentation.

Source : Link , Question Author : Vladyslav K , Answer Author : Sebastian Kessel

Leave a Comment