function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vivek KidambiVivek Kidambi 

How do i get record type of a record using the ID?

I am trying to use schema object to retrieve record type using the ID. I am able to retrieve the object name say account using the below query, but how do i retrieve record type of the object using this information without SOQL

String objName = objId.getSObjectType().getDescribe().getName();  // Objid is the id of the record
Best Answer chosen by Vivek Kidambi
StephenKennyStephenKenny
Hi there,

I do not believe this is possible. To get the recordtype for a specific record you would have to query it, something like this:
Id accountRecordtypeId = [Select Id, RecordtypeId from Account where id=:Objid].recordtypeId;
Please remember to mark this thread as solved with the answer that best helps you.

Kind Regards
Stephen

 

All Answers

StephenKennyStephenKenny
Hi there,

I do not believe this is possible. To get the recordtype for a specific record you would have to query it, something like this:
Id accountRecordtypeId = [Select Id, RecordtypeId from Account where id=:Objid].recordtypeId;
Please remember to mark this thread as solved with the answer that best helps you.

Kind Regards
Stephen

 
This was selected as the best answer
Vivek KidambiVivek Kidambi
Thanks Steve. That helps