I want to query ids on a related list from a lead. When I look up the related list name in the wsdl it says:

<complexType name="Lead">
<element name="signrequest__SignRequests__r" nillable="true" minOccurs="0" type="tns:QueryResult"/>

But when I run the following query:

SELECT Id, signrequest__SignRequests__r.Id FROM Lead

I get this error:

ERROR at Row:1:Column:12

  • For better solution you need to post your code and exact error what you have received. – Nihar Jul 14 '17 at 9:05
  • @Nihar this is my code from the Query editor in the Dev. console – Jenssen Jul 14 '17 at 9:09
  • What i understood is : Lead is Parent and signrequest__SignRequests__c child of Lead, you are suppose to get the Id of child from Lead. right ? – Nihar Jul 14 '17 at 9:13
  • @Nihar Indeed, Lead is Parent and signrequest__SignRequests__c child of Lead – Jenssen Jul 14 '17 at 9:19

You can get the related list records by using the following query,

Do the following steps :

  1. Go to your signrequest__SignRequests__c object

  2. Click on your Parent object lookup field (here you are using LEAD)

  3. copy the child relationship name from this lookup field (See image i have used parent Account & child contact to show you example)

  4. Use this child relationship name to your inner query.

  5. Finally you can use the following query to your developer console and you will get your expected result.

    Select Id, (select Id from `Your child relationship name`) from Lead

enter image description here

| improve this answer | |
  • the the child relationship name from the lookup field didnt work but the wsdl name did so the solution was: Select Id, (select Id,Name from signrequest__SignRequests__r) from Lead Thanks!! – Jenssen Jul 14 '17 at 9:36
  • Nice work !!! :) – Nihar Jul 14 '17 at 9:39
  • @ Nihar how do I do a second inner query, i want to get the attachment fields, the following didnt work: SELECT Id,(SELECT Id,Name (SELECT Name, Body FROM NotesAndAttachments) FROM signrequest__SignRequests__r) FROM Lead I get the error: Unknown error parsing query – Jenssen Jul 14 '17 at 10:05
  • You can use this for getting Lead's attachments : select Id , (select Id from Contacts), (Select Id from Attachments) from Account – Nihar Jul 14 '17 at 10:10
  • I meant attachments from signrequest__SignRequests__c, but I figured out you cant do 3rd level query from SOQL – Jenssen Jul 14 '17 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.