You need to sign in to do that
Don't have an account?
S D
Help with SOQL
Hi, am new to SOQL and trying to learn with workbook : but somehow I have observed none of the SOQL for parent child traversing works for me :I am executing this from Developer console and WorkBench. Both giving the below error:
My SOQL is :
select id, name, (SELECT Name
FROM Job_Application__r)
from Position__c
Just trying to execute the query from workbook. Is there any setting required to make in tools.??
Thanks!!
My SOQL is :
select id, name, (SELECT Name
FROM Job_Application__r)
from Position__c
Just trying to execute the query from workbook. Is there any setting required to make in tools.??
Thanks!!
I've seen a couple people struggling with this lately, but the best way I have found to determine the Child Relationship API name (in this case it is Job_Applications__r) is to do the following:
-
Go to Setup->Create->Objects (Or Setup->Customize)
-
Look at the fields of the *Child* Object in the relationship
-
Click on the Parent relationship (In this case it would be a M/D or Lookup to Position__c)
-
Take a look at the "Child Relationship Name"
-
If it's a managed package field, add namespace__ before it
-
If it's a custom relationship, then add the __r after it.
In the example below, I would use "Accounts__r".All Answers
You need to enable parent relationship queries in workbench to be able to use relationship queries.
Click on workbench Icon >> Settings >> Allows SOQL Parent Relationship Queries >> Apply Settings.
If this helps, mark this as best answer.
Thanks,
N.J
Have even executed this on Developer Console. Still the same.
N J is 100% correct.
And also i think you forget to write ' S '.
I mean to say that is it right name of child relationship?
i think it should be " Job_Applications__r ".
So try this
Regards
Virendra
I have even verified this against the Object Definition API name from application.
ALso I tried to write a similar query on Merchant and LineItem and it is failing as well. so thought of putting this query in here.
But do you see any other particular reason with the error message pasted?
I've seen a couple people struggling with this lately, but the best way I have found to determine the Child Relationship API name (in this case it is Job_Applications__r) is to do the following:
-
Go to Setup->Create->Objects (Or Setup->Customize)
-
Look at the fields of the *Child* Object in the relationship
-
Click on the Parent relationship (In this case it would be a M/D or Lookup to Position__c)
-
Take a look at the "Child Relationship Name"
-
If it's a managed package field, add namespace__ before it
-
If it's a custom relationship, then add the __r after it.
In the example below, I would use "Accounts__r".However I want to know on pt 5, mentioned in your steps.
In case of Managed Package , could you show an example to do this ? and would this also be applicabe to Unmanaged Packages
If you look at the object detail or field detail, you should see information regarding the namespace, if there is one.
Here's an example I found in my dev org. This managed package / custom field has a namespace of "pca"
To write a subquery to pull in related businesses for a parent Setting object, I would write the following SOQL, with the namespace followed by two underscores:
Please note that the prefix__ is used primarily for code in an org where the managed package is installed. I don't necessarily need to specify the prefix in an org where I am developing the managed package, for instance.