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
ajay ambatiajay ambati 

soql not retriving record from parent object

1,hi,iam having two objects oppurtunity(parent) and another is custom object name is TopXDesignation__c(child)  having MDR RELATIONSHIP and i want to retrieve records from parent i,e opportunity so, i wriiten soql query below
           lstopp=[select id,Name,CloseDate,StageName,(select id,name,Document_Attached__c from  TopXDesignation__r) from Opportunity];
 
but iam getting below error:
Didn't understand relationship 'aTopXDesignation__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.


2,and also iam tried follwing type query not geeting
lstopp=[select id,Name,CloseDate,StageName,(select id,TopXDesignation__c.name,TopXDesignation__c.Document_Attached__c from TopXDesignation__c.TopXDesignation__r) from Opportunity];

ERROR IS :
TopXDesignation__c.Document_Attached__c from TopXDesignation__c.TopXDesignation__r)
                                             ^
ERROR at Row:1:Column:116
Didn't understand relationship 'TopXDesignation__c' in field path. 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.
PLEASE ANSWER IT


   
UC InnovationUC Innovation
Hi Ajay,

You might need to check the child relationship name. This can be found in the opportunity lookup field under Master-Detail options for the TopXDesignation object. Chances are the child relationship name is the issue. When you find it simply append the __r and do something like this
 
lstopp = [SELECT Id,
                 Name,
                 CloseDate,
                 StageName,
                 (SELECT Id,
                         Name,
                         Document_Attached__c 
                  FROM <CHILD_RELATIONSHIP_NAME>__r) 
          FROM Opportunity];

Hope this helps!

AM
ajay ambatiajay ambati
iam given below querys
1,lstopp = [SELECT Id, Name, CloseDate, StageName, (SELECT Id, Name, Document_Attached__c FROM Opportunitys__r) FROM Opportunity];
2,,lstopp = [SELECT Id, Name, CloseDate, StageName, (SELECT Id, Name, Document_Attached__c FROM TopXDesignation__r) FROM Opportunity];
still iam not getting error not solved