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 ...
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 ...
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'
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, ...
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....
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
...
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).
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 ...
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....
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 ...
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 ...
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 ...
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?...
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 ...
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 ...
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()....
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 ...
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 ...
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....
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 ...
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 ...
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.
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.
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 ...
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.
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
record-type × 672apex × 152
visualforce × 65
page-layout × 59
picklist × 54
profile × 46
soql × 30
trigger × 26
opportunity × 26
case × 24
lightning-web-components × 22
account × 22
workflow × 20
lightning × 19
visual-workflow × 19
unit-test × 18
custom-object × 18
administration × 17
lightning-aura-components × 16
rest-api × 16
validation-rule × 16
metadata-api × 14
permissions × 12
person-accounts × 12
managed-package × 11