+ Start a Discussion
HelloSanHelloSan 

unable to execute the following query? Is it something obvious? Custom_Object__c has a master relationship to Opportunity

[Select id,year__c,(select id,service_year__c from Order__r) From Opportunity];
Best Answer chosen by HelloSan
Anirudh SinghAnirudh Singh
Hi,

Please go to Order object and then click on the field linked to the Opportunity. On the right hand side you will see 'Child Relationship Name', now copy this and append __r. And then use in the query.

For Example,
If the Child Relationship Name is abc, then the query should look like:
[Select id,year__c,(select id,service_year__c from abc__r) From Opportunity];

Please let me know if this helps.
If yes, please mark the question as Solved.


Thanks and Regards,
Anirudh Singh

All Answers

Anirudh SinghAnirudh Singh
Hi,

What is the name of your child object?

Thanks and Regards,
Anirudh Singh
RAM AnisettiRAM Anisetti
Mostly it is like...

[Select id,year__c,(select id,service_year__c from Orders__r) From Opportunity];
HelloSanHelloSan
Object Name : Order
API Namer : Order__c
Anirudh SinghAnirudh Singh
Hi,

Please go to Order object and then click on the field linked to the Opportunity. On the right hand side you will see 'Child Relationship Name', now copy this and append __r. And then use in the query.

For Example,
If the Child Relationship Name is abc, then the query should look like:
[Select id,year__c,(select id,service_year__c from abc__r) From Opportunity];

Please let me know if this helps.
If yes, please mark the question as Solved.


Thanks and Regards,
Anirudh Singh
This was selected as the best answer