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
Rakesh M 20Rakesh M 20 

how do i get child record's record type from parent record record type in soql

Hi Folks,
Please help to write SOQL Query for this







Thanks in advance
AbhinavAbhinav (Salesforce Developers) 
Hi Rakesh,

I guess you are looking for something similar.
 
Select Id,RecordType.Name,(select id, RecordType.Name from contacts) from Account where RecordType.Name= 'TestRecordType'

Hope it helps.Please mark it as best answer so that other find it useful.

Thanks!
 
Suraj Tripathi 47Suraj Tripathi 47

Hi Rakesh,

Please find the solution. "how do i get child record's record type from parent record record type in soql".

List<Account> accountList=new List<Account>();
accountList=[select id,(select id,RecordType.Name from Opportunities),RecordType.Name from Account where RecordType.Name='abc'];

for(Account ac:accountList){
 for(Opportunity op:accountList.Opportunities){

}
}
 

for custom objects

List<Family__c> families  = [ select Id,RecordType.Name ( select RecordType.Name, Family__c, Family_Member__c From Family_Members__r ) from Family__c where Id IN ( select Family__c from Family__Member__c where Id IN :setOfAllMembers ) ];

 

Then, you'd have to loop through them like this to get your family members.

 

List<Family_Member__c> members = new List<Family_Member__c>();

 

for( Family__c f : families ) {

      for( Family_Member__c fm : families.Family_Members__r ) {

            members.add( fm );

      }

}

Please mark it as the Best Answer so that other people would take reference from it.

Thank You

 

lucy tonilucy toni
Hey,

If you can to query the parent record from child then you need to look for API Name for parent record in the child object.
It will be like this.
 
select id payment__c payments__c
http://www.sfdc99.com/2013/06/09/example-how-to-write-a-cross-object-soql-query/
Regards: Gepco Bill (https://gepco.pk/)
 
mukesh guptamukesh gupta
Hi Rakesh,

you can follow below SOQL 
 
select Account.RecordType.Name,(select id, RecordType.Name from Opportunities )  from Account

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh