You need to sign in to do that
Don't have an account?
john dsouza
child to parent query
Hello
I have two custom objects , fan__c and subscription__c
Fan object has fields (ID, email__c)
subscription object has fields(ID,fan_ID__c,mailing_list_name)
subscription object has a lookup to fan object as : Fan_ID__cLookup(Fan)
pls help in framing the subscription query from child to parent where child is subscription object and parent is fan object.
I want to frame a query on subscription object that will fetch the related email of fan object
pls help me out
thanks
JohnD
I have two custom objects , fan__c and subscription__c
Fan object has fields (ID, email__c)
subscription object has fields(ID,fan_ID__c,mailing_list_name)
subscription object has a lookup to fan object as : Fan_ID__cLookup(Fan)
pls help in framing the subscription query from child to parent where child is subscription object and parent is fan object.
I want to frame a query on subscription object that will fetch the related email of fan object
pls help me out
thanks
JohnD
Please try to modify your query as below it will help !! Let me know if it helps
Thanks
Manoj
All Answers
You can frame you rquery like below .
Let me know if it helps !!
Thanks
Manoj
If you want to query email of fan object from subscription object , you should write your query like this :
Select Name, fan__r.Email__c from subscription__c
Hope it helps !!
Cheers !!
Thanks for the query.
the query doesnt fetch the emails.
I created a loop to fetch email. But its not showing up.
for(subscription__c sub:subList)
{
system.debug(sub);
}
can u le tme know how to improvise this?
thanks
JohnD
OK, I improvised this as foolows and got the emails.
List<subscription__c> subList=[SELECT Id,Fan_ID__r.email__c FROM subscription__c
LIMIT 50];
for(subscription__c sub:subList)
{
system.debug(sub.fan_ID__r.email__c);
}
There is one more point where I require a clarification to close this post.
In addition to the mentioned custom objects, I have another custom object as Mailing_List__c which has the field as Mailing_List_Name__c.
Now Mailing_List__c is a master object and related child object is subscription__c, so there is a master detail relaitonship between
Mailing_List__c and subscription__c .
so Mailing_List_ID__c is the api name in Master-Detail(Mailing List)
Now I need to fetch mailing_list_Name__c from the subscription query I mentioned above.
any help in this will be appreciated.
Rather than storing the return in an list variable can it be a Map?
I am novice in using map so I am asking.
thanks
JohnD
Please try to modify your query as below it will help !! Let me know if it helps
Thanks
Manoj
If I remove the LIMIT clause from above query it throws 50001 rows error.
How can I avoid this?
Thanks
JohnD
You can add more filter to the query as per your requirment ,else you need to go for asyncronous apex .
Thanks
Manoj
Batch apex sounds gr8. I think I have mo other option left.
Do you mind If I keep this post open for a couple of days?
Thanks
John
Thanks
Manoj
My issue is resolved.
Thanks
John