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
TehNrdTehNrd 

Query related objects requires hardcoding object ID?

We have a custom object (NSP) that has a look up field to an opportunity. I would like to query the opportunity object but also determine if the opp has any NSPs attached to it. I can build out the query with the force.com IDE but this is what I get:

 

 

select Id, (Select Id, Name From R00N50000001gFM3EAM limit 1) from Opportunity

It seems a little bizarre the relationship name is a pseudo ID. I would rather not have to hard code this value if possible. Any one have ideas?

 

Thanks,

Jason

 

 

Best Answer chosen by Admin (Salesforce Developers) 
withoutmewithoutme
I think you can go to the custom field definition in the UI and set the child relationship name. What you are seeing now is the auto genrated relationship name.

All Answers

withoutmewithoutme
I think you can go to the custom field definition in the UI and set the child relationship name. What you are seeing now is the auto genrated relationship name.
This was selected as the best answer
hisrinuhisrinu

you can try like this

 

select Id, (Select Id, Name From plural Label of the object limit 1) from Opportunity

 

TehNrdTehNrd

Thanks withoutme. That worked.

 

hisrinu, this will work by default for parent-child relationships but you have to manually define this label for lookups.

Message Edited by TehNrd on 05-06-2009 08:36 AM