I'm getting error while moving to prod.

ERROR - Didn't understand relationship 'DB_Line_Item__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

My query is as below -

    tc = [SELECT id,Name,Vendor_Code__c,Total__c, Debit_Note_Date__c,Category_Manager__c,Vendor_Name__c,Parent_Category__c,Promotion__c,Department__c,Category1__c,(SELECT id,Adpro__c,Amount__c,Cost_Center__c,CurrencyIsoCode,Currency__c,Debit_Note__c,Description__c,Description_Model__c,name, GL__c,GP__c,LP__c,Provision__c,Ref__c,Total__c FROM DB_Line_Item__r ) FROM Debit_Note__c  where ID =: id];

Please help

2 Answers 2


tl;dr; Change your relationship name from "DB_Item__r" to "DB_Items__r"

Explanation: Navigate to Setup -> Object Manager -> DB Line Item.

Look at the relationship field (Lookup or Master Detail) on DB Line Item to Debit Note. There should be an attribute on the field definition called "Child Relationship Name". I believe that yours will say "DB Line Items", which means that the API name for the child relationship name would be "DB_Line_Items__r". I have attached a photo of where to find the child relationship name for a field called "Loan" with a lookup to Opportunity in an Org I am working in right now. Child Relationship Name


In case you are not sure about relationship API name then describe the object from Workbench and check the relationship API name.

May be it is DB_Line_Items__r

You must log in to answer this question.

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