Skip to main content
33 votes

What would be the best approach to get the recordtype id

Until now, we used zachelrath's solution, and it worked wonderfully. As of v43.0 (Summer '18), however, the proper way to do this is to simply use getRecordTypeInfosByDeveloperName. It eliminates a ...
Charles Koppelman's user avatar
21 votes
Accepted

Use Name vs DeveloperName for RecordType?

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 ...
Sebastian Kessel's user avatar
21 votes
Accepted

How to get the list of record type Id of an sObject by SOQL

By querying the recordType object and filtering by the sObjectType select Id,Name from RecordType where sObjectType='Account'
benahm's user avatar
  • 2,627
16 votes

How do I get the intersection of RecordType and Picklist values inside Apex?

You can make use the User Interface API to get picklist values based on record type, https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_picklist_values.htm However, ...
psun's user avatar
  • 371
16 votes

getRecordTypeInfosByName()

getRecordTypeInfosByName() looks for Label. After summer '18 preview, Salesforce is going to support getRecordTypeInfosByDeveloperName() delivered: https://developer.salesforce.com/docs/atlas.en-us....
Ayub's user avatar
  • 3,543
16 votes
Accepted

Inserting test record with record type

You need to set the Id not the name. First fetch the Id Id stExam = Schema.SObjectType.Student_Records__c.getRecordTypeInfosByName().get('Student Exam Records').getRecordTypeId(); and then assign it ...
Tushar Sharma's user avatar
16 votes
Accepted

Flow Builder - Dynamically Get Queue Id by Name

Use the GetRecords Element and Query on the Group object. Add the filter to make sure Type = Queue, then add the filter for DeveloperName = (queue name).
Kristina Dillon's user avatar
15 votes

How to get the list of record type Id of an sObject by SOQL

While this can be accomplished with SOQL, SOQL queries are a precious resource and we have but a scant few in each transaction. There is a way to get this information without using a single query by ...
Derek F's user avatar
  • 63.2k
14 votes
Accepted

Getting RecordTypeId selected from 'Record Type Selection' Page, in a lightning component that overrides create screen

Summer'18 update provided a new interface 'lightning:hasPageReference'. You can now access the recordTypeId in your controller as below: var recordTypeId = component.get("v.pageReference").state....
Vinod Rondla's user avatar
11 votes
Accepted

Record type showing NULL in trigger

Only the object's base fields are loaded from the database in triggers. To get related objects, you need to either query for them or use describe calls. In this specific case, you would use a describe ...
sfdcfox's user avatar
  • 500k
11 votes

Cannot deactivate record type because it is referenced by other entities

I finally found the answer to this after hours of searching. This happens when you have setup a community audience that references the record type you are attempting to deactivate. It seems as though ...
Clay Chipps's user avatar
11 votes

Get custom Picklist value in LWC without Record Type

Use the "null" record type Id, "012000000000000AAA" as the record type Id. @wire(getPicklistValues, { objectApiName: PRICEBOOK_OBJECT, recordTypeId: '012000000000000AAA'}) This is ...
sfdcfox's user avatar
  • 500k
9 votes

Lightning Web Components: navigate to the 'new' object page passing in specific record type Id?

I did find a workaround/hack your welcome to try. I looked at the URL when I Went to the account page, and hit the new button and I found a url that looks like this: '/lightning/o/Account/new?...
Joshua Cruz's user avatar
8 votes

Get Record Type Developer Name without SOQL Query

it will be possible from Summer'18 https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm Get the Developer Name for Record Types More Easily We added Apex ...
user682217's user avatar
  • 1,171
8 votes

Getting Page Layout associated to a Profile/RecordType

If you are interested in solution which would work only for Salesforce Classic, I have it. It is possible to make Tooling API ProfileLayout Object Query [ select Layout.Name from ProfileLayout where ...
Patlatus's user avatar
  • 17.4k
8 votes

Getting the record type ID via Apex

String gsRecordTypeID = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Record Type Label').getRecordTypeId(); - String gsRecordTypeID = Schema.getGlobalDescribe().get('Case').getDescribe()....
Avinash's user avatar
  • 2,131
8 votes

Getting the record type ID via Apex

Please note that getting record type by it's label is tricky when you have multi-language org, because labels can depend on user's language. The best would be to retrieve record types by using ...
Wookie88's user avatar
  • 733
8 votes
Accepted

Apex Test class (Field is not writeable: CampaignMember.RecordTypeId)

Documentation about RecordTypeId field on CampaignMember says: ID of the record type assigned to this object. To change the record type, modify the CampaignMemberRecordTypeId field on the ...
Oleksandr Berehovskyi's user avatar
8 votes
Accepted

No such column 'DeveloperName' on entity 'RecordType' after Summer '19 release on sandbox

Please recompile all classes in org by using compile all classes link on apex classes page under setup or you can do runAllTest in org which will recompile the covered classes. This will fix the issue....
Ashish Sharma's user avatar
7 votes

Custom Field Definition ID: bad value for restricted picklist field: RecordType

I have the same error for scratch orgs on some standard objects (Account, Contact, Lead, and Opportunity). As a workaround, I found that after removing "recordTypeTrackHistory" from the ...
Thomas Minney's user avatar
7 votes
Accepted

getRecordTypeInfosByName()

It's not entirely clear in the documentation on the gerRecordTypeInfosByName() method, but the documentation does make a mention of using the 'label' getRecordTypeInfosByName() Returns a map ...
Derek F's user avatar
  • 63.2k
7 votes

Use Name vs DeveloperName for RecordType?

Use a unique identifier wherever possible to query for vital configuration data. In this case, DeveloperName is unique, where Name is not. So there is a clear and compelling case to use the former.
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

Invalid field RecordTypeId for SObject Case

You need to add at least one record type to your case object (Setup > Customize > Cases > Record Types) before you can use the RecordTypeId field.
sfdcfox's user avatar
  • 500k
6 votes
Accepted

Record type selection screen is not shown prior to case creation

Please check if any default Record Type is selected for that user by visiting User Name(in header) > My Settings > Display and layout > Set Default Record Types. If you have enabled the Record Type ...
Saroj Bera's user avatar
  • 14.8k
6 votes

Use Name vs DeveloperName for RecordType?

Developer name remains static, label can be changed to a different value. Best practice is to always use developer name to get recordtype Id.
Raul's user avatar
  • 18.9k
6 votes

Error when pushing code: "Field does not exist: RecordTypeId"

You can put your objects into your source control (which you should, and then deploy them along with all the code. Your record types will also be included as part of the deployment. As long as the ...
sfdcfox's user avatar
  • 500k
6 votes

SFDX -How to Export data with record types to put in a scratch / qa org

I had this same issue, so I wrote a SFDX plugin to help. In the export query, you select RecordType.DeveloperName along with other fields from your object. Then run my plugin against the JSON data ...
William Young's user avatar
6 votes

How to cover condition referencing record type name in apex test class?

I think you're referencing an SObjectField token. Make sure you're referencing a record's record type name: if(someRecord.RecordType.Name == 'Record Type 1') { // ... Using the other form is ...
sfdcfox's user avatar
  • 500k
6 votes
Accepted

Using Task Record Type via REST API

The picklist-values-per-record-type issue is an old problem to which there's only recently a semi-decent solution. There's a number of ways to approach this, and if you're already using the API, the ...
David Reed's user avatar
  • 93.4k
6 votes
Accepted

Record type behavior not working on edit record layout

The Record Type is an attribute of the record, not of the profile. Record types can be enabled on a per-profile basis, which changes what record types members of that profile can create (not has no ...
David Reed's user avatar
  • 93.4k

Only top scored, non community-wiki answers of a minimum length are eligible