function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Option 1 :- You can check by record
Select id,Name,recordTypeid,recordType.Name from Account limit 5;
Option 2 :- By Describe call
Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();
..............................
private String getRecordTypeSelectedId(String recordTypeName){
String rtId;
List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'Work_Order__c']);
for(RecordType rt : rtList) {
if(rt.Name == recordTypeName) {
rtId = rt.Id;
}
}
return rtId;
}
.........................
Option 3 :- Direct query record by SOQL
select id,name from recordType where SobjectType ='account';
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
All Answers
There is no need to query. you can get the record type id using schema.
YOUR_OBJECT_API_NAME.sObjectType.getDescribe().getRecordTypeInfosByName().get('YOUR_RECORD_TYPE_NAME').getRecordTypeId()
Option 1 :- You can check by record
Select id,Name,recordTypeid,recordType.Name from Account limit 5;
Option 2 :- By Describe call
Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();
..............................
private String getRecordTypeSelectedId(String recordTypeName){
String rtId;
List<RecordType> rtList = New List<RecordType>([Select ID, Name From RecordType Where sObjectType = 'Work_Order__c']);
for(RecordType rt : rtList) {
if(rt.Name == recordTypeName) {
rtId = rt.Id;
}
}
return rtId;
}
.........................
Option 3 :- Direct query record by SOQL
select id,name from recordType where SobjectType ='account';
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help