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
Suraj_BahaleSuraj_Bahale 

Account acct = [SELECT Id FROM Account LIMT 1); Given the code above, how can a developer get the type of object from acct?

A. Call "acct.getSObjectType()"
B. Call "Account.getSObjectType()"
C. Call "Account.SObjectType".
D. Call "acct.SObjectType''.
Best Answer chosen by Suraj_Bahale
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi suraj,

Use acct.getsobjecttype() to get type of object.

Please refere below link which might help you further
(https://help.salesforce.com/articleView?id=000340200&language=en_US&type=1&mode=1)

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi suraj,

Use acct.getsobjecttype() to get type of object.

Please refere below link which might help you further
(https://help.salesforce.com/articleView?id=000340200&language=en_US&type=1&mode=1)

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
This was selected as the best answer
Suraj_BahaleSuraj_Bahale
Account acct = [SELECT Id FROM Account LIMIT 1];

(corrected Que)
Deepali KulshresthaDeepali Kulshrestha
Hi Suraj,

I've gone through your requirement and you can see the below code for get the record type of any sobject:
Apex code:

public class getSobjectClass {
    
 public static void getSobjectMethod()
 {
     Account acc=[select id,Name from Account limit 1];
     
     String typeOfSobject=acc.getSobjectType().getDescribe().getName();
     System.debug('acc type>>>'+typeOfSobject);
 }
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com