+ Start a Discussion
Rahul Reddy 1Rahul Reddy 1 

Soql Query for Master Detail Object

Amount Object to retrive and print  Amount and Payment Type from Amount Object and Customer Name (Master Detail), Customer Email, Customer Phone from Customer Object

    List <Amount__c> AM = [SELECT Amount, Payment_Type__C, Customer_Name__r.Name,Customer_Email__c, Customer_Phone__c From Amount__C];
System.debug(AM);

It prints some reference ID for Customer_Name__r.Name instead of the the customer name also not sure how to print Customer_Email__C and Customer_Phone__C.

Help would be highly appreciated.
 
Himanshu ParasharHimanshu Parashar
Hi Rahul,

You can run following query
 
List <Amount__c> AM = [SELECT Amount, Payment_Type__C, Customer_Name__r.Name,
Customer_Name__r.Customer_Email__c,Customer_Name__r.Customer_Phone__c From Amount__C];
System.debug(AM);

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Rahul Reddy 1Rahul Reddy 1
Himanshu

It still prints reference for Customer_Name__r.Name instead of the Name.

Regards
Rahul
Himanshu ParasharHimanshu Parashar
Hi Rahul,
Are you able to get Customer_Email__c and Customer_Phone__c ? if yes kindly check Name field record type whether it is set as AutoNumber instead of text.

Thanks,
Himanshu