+ Start a Discussion
sundhar.mks1.3962649227519546E12sundhar.mks1.3962649227519546E12 

How to get the Record type Dynamically?

Best Answer chosen by sundhar.mks1.3962649227519546E12
BalajiRanganathanBalajiRanganathan
You can use Describe

Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();

For more details, refer the link below.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_class_Schema_RecordTypeInfo.htm

 

All Answers

BalajiRanganathanBalajiRanganathan
You can use Describe

Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();

For more details, refer the link below.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_class_Schema_RecordTypeInfo.htm

 
This was selected as the best answer
sundhar.mks1.3962649227519546E12sundhar.mks1.3962649227519546E12
Hi Balaji,

One Custom object "SERVICE" have four record type, how to get without using URL?

NOTE:  i have used the record type URL "RecordType=012D0000000V9q7&ent=01ID0000000RxJh"  any other way to get record type kindly give any example or code

Thanks.
Akshay DeshmukhAkshay Deshmukh
try this


Id recTypeId = [select Id from RecordType where Name =: "Enter Record Type Name Here"and SobjectType =:" Enter SObject Name here" ];
e.g.
[select Id from RecordType where Name =: 'SalesRep' and SobjectType =: 'Account'];