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
Kondal Rao learnerKondal Rao learner 

pls help me regarding accessing the child object fields

hi experts,

 

My requriement is that to access the fields of the child custom  object that deal_process_assocation , deal is parent object  so i wrote a query on that but its showing error like "Error: Compile Error: Didn't understand relationship 'Deal_Program_Association__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. at line 13 column 20" , there is relationship between deal and deal process association pls help me

 

this is query:

 

list<deal__c>l=[select Id, Name, Distributor__c, End_Customer__c, Industry__c, Partner_Specializations__c,Partner_Tier__c,Product_Category__c,Segment__c,(select id,Incentive__c ,Dollar_Incentive__c from Deal_Program_Association__r) from Deal__c];

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9
Assuming deal is the parent object and you want to do parent to child the query should be something like

list<deal__c>l=[select Id, Name, Distributor__c, End_Customer__c, Industry__c, Partner_Specializations__c,Partner_Tier__c,Product_Category__c,Segment__c,(select id,Incentive__c ,Dollar_Incentive__c from Deal_Program_Associations__r) from Deal__c];

Please note the Parent to child relationship are generally refered by plurals like "Deal_Program_Associations__r" instead of "Deal_Program_Association__r"

All Answers

brdbrd

Hi,

 

Try like this if there is relationship between deal__c and deal_program_association__r:

 

list<deal__c>l=[select Id, Name, Distributor__c, End_Customer__c, Industry__c, Partner_Specializations__c,Partner_Tier__c,Product_Category__c,Segment__c,Deal_Program_Association__r.Incentive__c ,Deal_Program_Association__r.Dollar_Incentive__c  from Deal__c];

Avidev9Avidev9
Assuming deal is the parent object and you want to do parent to child the query should be something like

list<deal__c>l=[select Id, Name, Distributor__c, End_Customer__c, Industry__c, Partner_Specializations__c,Partner_Tier__c,Product_Category__c,Segment__c,(select id,Incentive__c ,Dollar_Incentive__c from Deal_Program_Associations__r) from Deal__c];

Please note the Parent to child relationship are generally refered by plurals like "Deal_Program_Associations__r" instead of "Deal_Program_Association__r"
This was selected as the best answer