You need to sign in to do that
Don't have an account?
Bill Woodson
query related list of parent object of custom object
Hello,
I need to get a list of custom objects from a parent object of a custom object using soql. The parent object is the standard Contact record
Ex.
SpecialInfo__c.Contact_Record__r.CustomNotes__r
psuedo code:
for each CustomNote
Get [some CustomNotes fields] From CustomeNotes
where Contact_Record.parentid = SpecialInfo.id
Thanks!
I need to get a list of custom objects from a parent object of a custom object using soql. The parent object is the standard Contact record
Ex.
SpecialInfo__c.Contact_Record__r.CustomNotes__r
psuedo code:
for each CustomNote
Get [some CustomNotes fields] From CustomeNotes
where Contact_Record.parentid = SpecialInfo.id
Thanks!
SpecialInfo__c Sinfo = new SpecialInfo__c([Select Contact__c From SpecialInfo__c
where ID =: SpecialInfo__c.id]);
and then use the following:
Select [some CustomNotes fields] From CustomeNotes
where Contact__c =: Sinfo.Contact__c
Hope I've understood the schema correctly and this helps!
All Answers
If that is true, you can write:
Get [some CustomNotes fields] From CustomeNotes
where Contact__c =: SpecialInfo__c.Contact__c
provided you already have the value of SpecialInfo__c.Contact__c
SpecialInfo__c Sinfo = new SpecialInfo__c([Select Contact__c From SpecialInfo__c
where ID =: SpecialInfo__c.id]);
and then use the following:
Select [some CustomNotes fields] From CustomeNotes
where Contact__c =: Sinfo.Contact__c
Hope I've understood the schema correctly and this helps!
for(CustomNote__c note_record:[select id,
CreatedBy.Name,Body__c,LastModifiedDate
from CustomeNote__c
where Contact__r =: SpecialInfo__c.Contact_Record__c
and SpecialInfo__c.id =: Apexpages.currentPage().getParameters().get('id') ])
SpecialInfo__c spInfo = new SpecialInfo__c([select Contact_Record__c
from SpecialInfo__c
where id =: Apexpages.currentPage().getParameters().get('id')]);
Thanks for all your help!