You need to sign in to do that
Don't have an account?

Getting records from Multiple List using Soql
Hi,
I have a structure of Apex Class where I use 3 Lists to get records whch are related to each by a lookup.
The objects are Assessment Template, Tabs, Titles and Questions.
The lookups are as follows:
Main Events (Assessment Template Lookup)
|
Assessment Template (Tabs Lookup)
|
Tabs (Assessment Template Lookup)
|
Titles (Tab Lookup)
|
Questions (Title Lookup)
So user creates a Assessment template record and creates the necessary tabs, Titles and then questions.
The issue i am facing here is that a template record can have multipe tab records....a tab record can have multiple title records and so on a title record can have multiple question records...
f i had to show each of these relatively on a visualforce page using controller...how do I match the Lists in Soql?
I tried using this way but the result takes all the question records and compares with all the title records and returns all the questions under both title names i used....instead of returning particular question records for a given title n so on for tabs....
Public class ParamTesting { public List <Id> TLid = new List<ID>(); public List <Id> TLd = new List<ID>(); public List <Decimal> TLtitleOrder = new List<Decimal>(); public String TooId {get;set;} public List <Title__c> TL {get;set;} public List <Tabs__c> TB {get;set;} public List <Questions__c> QT {get;set;} public List <Questions__c> QAT = new List<Questions__c>(); public Set <Questions__c> QATs = new Set<Questions__c>(); string EtihadtId; public ParamTesting(ApexPages.StandardController controller) { EtihadtId = ApexPages.currentPage().getParameters().get('id'); Etihad_Events__c Et = [Select id, Assessment_Template__c from Etihad_Events__c where id =: EtihadtId]; Assessment_Template__c AT = [Select name from Assessment_Template__c where id =: ET.Assessment_Template__c]; TL = [Select id, name, Title_label__c, Question_order__c, Title_Order__c from Title__c where Title__c =: AT.id order by Title_Order__c]; public List <Assesment_Details__c> getFetchQns() { for(integer j=0; j<TL.size(); j++) { system.debug('Size' + TL[j].id); TLid.add(TL[j].id); TLtitleOrder.add(TL[j].Title_Order__c); } TAL = [Select id,name,title_Order__c,title__c from Title__c where title__c =:TLId]; system.debug('TAL' +TAL); for(integer k=0; k<TAL.size()-1; k++) { system.debug('Size' + TAL[k].name); TLd.add(TAL[k].id); } QT = [Select Question_Label__c, Question_Order__c, Select__c, Title__c from Questions__c where title__c =:TLid and Title__r.Title_Order__c =:TLtitleOrder]; system.debug(' TitleId : ' + TLid); return QAT; return QT; } }
Right now I am neglecting tabs. Once title works then i can include it in the hierarchy.
Is there any way we can call the records from 2 or more Lists from lookup matching?
If you have encountered the same problem please provide me a solution to it.