You need to sign in to do that
Don't have an account?
Problem with nested query on Master/Details relationship
Hi, I have two objects with Master / Detail relationship
Master: API Name: SD_User__c
Object Name:SD_User SD License
Detail: API Name: SD_License_in_Opportunity__c
Object Name: SD_License_in_Opportunity
Plural Label: SD Licenses in Opportunity
Singular Label: SD License in Opportunity
Custom field that connect to Master:
API Name: SD_User__c
Field Name: SD_User
Field Label: SD License
I have a nested query that works fine in Sandbox but i can’t run it properly in production because of incorrect
From nested section (from detail object)
There is a Sandbox query:
for (SD_User__c sdUserList : [SELECT Id,
(select IsGlobalOpportunity__c, Opportunity__c From R00NT00000014FUrMAM ), Contact_Name__c
FROM SD_User__c WHERE Contact_Name__c in :conID and IsDeleted=false])
{
SD_License_in_Opportunity__c[] sdOpp = sdUserList.R00NT00000014FUrMAM;
for(Integer j=0;j<sdOpp.size();j++)
{ }
R 00NT00000014FUrMAM is ID of SD_License_in_Opportunity__c. SD_User__c
My problem is reproduce it in Production environment
I tried to take that production field Id 00N200000026lpO and to complete it to 18 chars (R00N200000026lpOEAB according to SF instructions, i hope i did correctly) – from 00N200000026lpOEAB
I tried also to write From Plural Label (to delete all spaces and to add __r) - from SDLicensesinOpportunity__r
SF doesn’t recognized it. I get an error:
Compile Error: line 1, column 30: Didn't understand relationship 'SDLicensesinOpportunity__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
Thank you
I would not use salesforce object ids in your query. HAve you tried using the below query:
You can get the exact relationship name via the schema explorer in the IDE. If you expand the object and then expand the "Child Relationships" and expand the SD_License_in_Opportunity you should see the "Relationship name".
This make your query environment independent.
All Answers
I would not use salesforce object ids in your query. HAve you tried using the below query:
You can get the exact relationship name via the schema explorer in the IDE. If you expand the object and then expand the "Child Relationships" and expand the SD_License_in_Opportunity you should see the "Relationship name".
This make your query environment independent.
Hi Anand,
Thank you for so quicly responce!!!
i found relation name in Eclipse (SD_Licenses_in_Opportunity) , added __r and it works GREAT in both environments
From SD_Licenses_in_Opportunity__r
Thank you very much !!!
Eric