I've a custom object for which I want the RecordTypeIDs returned along with a simple SELECT query.


$q1 = "SELECT Id, Name, RecordTypeID FROM Custom_Object__c";

Obviously this doesn't return the RecordTypeID field. How should I craft my query to get it returned along with in one pass?

  • 1
    I've no experience of PHP, but from other languages you would use Custom_Object__c[] cos = [SELECT Id, Name, RecordType.Id, RecordType.Name FROM Custom_Object__c]; and reference the record type ID via cos[i].RecordType.Id.
    – Keith C
    Oct 15, 2014 at 9:20
  • Thank you Keith. I tried your approach and the query does fetch RecordType.Id when I run it in Workbench. Funny thing is same query via PHP Toolkit isn't getting me the record type. While it's not throwing any errors, the RecordType.Id variable simply isn't present in the returned resultset. Oct 15, 2014 at 9:35
  • Check this link: stackoverflow.com/questions/5734033/…
    – Aditi Jain
    Oct 15, 2014 at 9:46
  • But come to think of it, the query in your question should return the record type ID... are you sure that doesn't work?
    – Keith C
    Oct 15, 2014 at 9:48
  • And also "RecordTypeId" is a valid field for any SObject having record type. Use can use this field directly in query to get Record Type Id.
    – Aditi Jain
    Oct 15, 2014 at 9:49


You must log in to answer this question.

Browse other questions tagged .