+ Start a Discussion
Ravi_SFDCRavi_SFDC 

Regarding RecordTypeID

1. I have a Custom Object and do have 5 record type's on the object.

2. I can add a record to the custom object manually.

MY QUESTION : At present I don't have any DATA in the object, the object is completely EMPTY. How can I query to see RECORDTYPEID's of the 5 record types of the object?

SELECT Id, RecordTypeId FROM CustomObjectName

But I would get an empty list.

Please suggest, your help is really helpful and appreciated.

Regards
Venkata

 

 

 

Best Answer chosen by Ravi_SFDC
ShivankurShivankur (Salesforce Developers) 
Hi Venkata,

Try running below code snippet into Anonymous window in developer console:
Id objectRecordTypeId = Schema.SObjectType.CustomObject__c.getRecordTypeInfosByName().get('CustomObject').getRecordTypeId();
Here API Name of object is "CustomObject__c" and record type name is "CustomObject".

or

You can use following SOQL query to fetch record type id's:
select Id,Name from RecordType where sObjectType='Custom_Object__c'
Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
 

All Answers

ShivankurShivankur (Salesforce Developers) 
Hi Venkata,

Try running below code snippet into Anonymous window in developer console:
Id objectRecordTypeId = Schema.SObjectType.CustomObject__c.getRecordTypeInfosByName().get('CustomObject').getRecordTypeId();
Here API Name of object is "CustomObject__c" and record type name is "CustomObject".

or

You can use following SOQL query to fetch record type id's:
select Id,Name from RecordType where sObjectType='Custom_Object__c'
Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
 
This was selected as the best answer
Ravi_SFDCRavi_SFDC
Hi Shivankur,

The SOQL Query worked with no issues.

Thanks
Venkata