You need to sign in to do that
Don't have an account?
SOQL Query (left join)
I have a custom object "SiteCart__c"
It has Master-Detail Relationship field "SiteProduct__c"
which is related to another custom object "SiteProduct__c"
"SiteCart__c" has two fields "Quantity__c" and related field "SiteProduct__c"
I want to retrieve fields of SiteCart__c such that it will show Quantity and name,description,price etc of related product filed.
I am using following query :
SELECT Quantity__c,(Select Name,Description__c,Price__c,Image__c From SiteProduct__r) FROM SiteCart__c
But this showing error
"Didn't understand relationship 'SiteProduct__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."
Please help me.
Ahhhh....
Correct me if I am wrong.
SiteCart is the child right ? which contains the master detail ?
And you want to access the fields of the parent object ? Site product ?
You can directly access the fields of the parent like this[The earlier query was for accesing child records from parent]
All Answers
Same old question!
The Master-Detail field will have a "Child Relationship Name" in the field detail. We generally add "__r" to this field name while doing relationship query.
The child relationship name generally is plural. So it should be something like "SiteProducts__r"
I tried with SiteProducts_r also but didnt worked either.
"Didn't understand relationship 'SiteProducts__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."
Check the Custom Relationship name of this field SiteProduct__c. It must have some different name not this 'SiteProducts__r'.
Check in the object field definition.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
I just guessed the name!
You actually should be doing what I instrcuted to
The Master-Detail field will have a "Child Relationship Name" in the field detail. We generally add "__r" to this field name while doing relationship query.
"Child Relationship Name" is "SiteProducts"
Although It was not that before i changed it to "SiteProducts"
And is still giving error.
Ahhhh....
Correct me if I am wrong.
SiteCart is the child right ? which contains the master detail ?
And you want to access the fields of the parent object ? Site product ?
You can directly access the fields of the parent like this[The earlier query was for accesing child records from parent]
Thanks it worked.