0

I'm making a query on Case Object to capture the cases created for a certain span of time. In this query, I'm including columns from the related Contact Record, and one of the things I need to capture is the Record Type of the related Contact Record.

Now, the issue is that I can use Contact.RecordTypeId however, I want to return the Label of the Record Type instead. Is this possible?

Here's my query so far:

SELECT Id, Contact.Id, Contact.Name, Contact.RecordTypeId
FROM Case

Thank you!

4
  • 1
    Did you try using this. SELECT Id, Contact.Id, Contact.Name, Contact.RecordTypeId,Contact.RecordType.Name FROM Case Nov 22, 2021 at 11:21
  • Hi @SaiPraveen - I was indeed doing this, but it only displays [Object object] when queried through DevConsole. I did try it on Workbench and Dataloader, and RecordType.Name is indeed working. Any explanation as to why it displays clunky in the Dev Console?
    – VanceSOQL
    Nov 22, 2021 at 11:34
  • 1
    As it is referring from another object called Record type so it refers as [Object Object]. You can write some sample apex code and check if it is returning correct value or not as below. list<Case> caselist=[SELECT Id, Contact.Id, Contact.Name, Contact.RecordTypeId,Contact.RecordType.Name FROM Case where id='5005j000008vTeVAAU']; system.debug('liscase'+caselist[0].Contact.RecordType.Name); Nov 22, 2021 at 11:43
  • 2
    If you want to check in workbench you need to enable 'Allows SOQL Parent Relationship Queries' setting in workbench so you will be able to see the name Nov 22, 2021 at 11:49

1 Answer 1

1

Yes, You can by using Contact.Recordtype.Name

SELECT Id, Contact.Id, Contact.Name, Product_Main_Group__c, Contact.Technology__c, Contact.RecordTypeId, Contact.Recordtype.Name FROM Case`.

Please let me know if it helps.

2
  • Hi @MohanRaj - I was indeed doing this, but it only displays [Object object] when queried through DevConsole. I did try it on Workbench and Dataloader, and RecordType.Name is indeed working. Any explanation as to why it displays clunky in the Dev Console?
    – VanceSOQL
    Nov 22, 2021 at 11:34
  • In developer console, Yes. It's provide response as object notation. Please refer this it's will answer your question. salesforce.stackexchange.com/questions/17916/…
    – Raj
    Nov 22, 2021 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .