i'm facing the following error while trying to save this. can someone tell me what im doing wrong please?
public class GanttDTO {
public class RecordDetail {
@AuraEnabled public String identifier;
@AuraEnabled public String parent;
@AuraEnabled public String name;
@AuraEnabled public String owner;
@AuraEnabled public String start;
@AuraEnabled public String due;
@AuraEnabled public String completed;
@AuraEnabled public String status;
@AuraEnabled public String sortorder;
@AuraEnabled public Record[] records;
}
public class Record {
RecordDetail record;
}}
and this is the class code
public class GanttData {
@AuraEnabled
public static void getData(String recordid, String objecttype){
//get onboarding
list<onboarding__c> onboardings_1 = new list<onboarding__c>();
if(objecttype == 'Account'){
onboardings_1 = [select id,name,
(select name, start_date__c, due_date__c, completed_date__c, sort_order__c, status__c from milestones__r order by sort_order__c asc),
(select name, start_date__c, due_date__c, completed_date__c, sort_order__c, status__c from task_trackers__r order by sort_order__c asc)
from onboarding__c
where account__c = :recordid];
}else if(objecttype == 'Onboarding'){
onboardings_1 = [select id,name,
(select name, start_date__c, due_date__c, completed_date__c, sort_order__c, status__c from milestones__r order by sort_order__c asc),
(select name, start_date__c, due_date__c, completed_date__c, sort_order__c, status__c from task_trackers__r order by sort_order__c asc)
from onboarding__c
where id = :recordid];
}
//loop through level 1
List<GanttDTO.RecordDetail> onbaordings = new List<GanttDTO.RecordDetail>();
//List<GanttDTO.Record> onboarding_dependants = new List<GanttDTO.Record>();
List<GanttDTO.RecordDetail> onboarding_dependants = new List<GanttDTO.RecordDetail>();
for(Integer i=0 ; i < onboardings_1.size() ; i++){
onboarding__c ob = onboardings_1[i];
if(ob.milestones__r != null){
List<GanttDTO.RecordDetail> milestones = new List<GanttDTO.RecordDetail>();
for(milestone__c m: ob.milestones__r){
GanttDTO.RecordDetail milestone = new GanttDTO.RecordDetail();
milestone.name = m.Name;
milestones.add(milestone);
}
System.debug('milestones:' +milestones.size()+ ':' +milestones);
onboarding_dependants.addAll(milestones);
}
if(ob.task_trackers__r != null){
List<GanttDTO.RecordDetail> tasktrackers = new List<GanttDTO.RecordDetail>();
for(task_tracker__c t : ob.task_trackers__r){
GanttDTO.RecordDetail tasktracker = new GanttDTO.RecordDetail();
tasktracker.name = t.Name;
tasktrackers.add(tasktracker);
}
System.debug('tasktrackers:' +tasktrackers.size() + ':' +tasktrackers);
onboarding_dependants.addAll(tasktrackers);
}
GanttDTO.RecordDetail onboarding = new GanttDTO.RecordDetail();
onboarding.name = ob.Name;
onboarding.records = new List<GanttDTO.RecordDetail>(onboarding_dependants);
onbaordings.add(onboarding);
}
System.debug('onbaordings:' +onbaordings);
}}
onboarding.records = new List<GanttDTO.RecordDetail>(onboarding_dependants);
this line throws an error : Illegal assignment from List<GanttDTO.RecordDetail> to List<GanttDTO.Record>