+ Start a Discussion
Sainath VenkatSainath Venkat 

Wrapper class to hold two objects data

I am pretty new to Salesforce apex development, so came accross one specific requirement where I need to create LWC component.
I have two objects
  1. Shadow_Note__c
  2. Case_History_Normalized__c
Based on picklist value I need to bind the data from above two objects and display it on LWC component, I tried below controller
public static Map<string,List<Shadow_Note__c>> populateTaggedNotesForCase(Id RecordId){
    //set<Id> caseRecordId = new set<Id>();
    String caseRecordId = '';
    List<Root_Cause_Analysis__c> rcaRecords = [Select Id, Case__c from Root_Cause_Analysis__c where Id =: RecordId order by CreatedDate desc];
    /*for(Root_Cause_Analysis__c rca: rcaRecords){
    if(rcaRecords.size() > 0)
        caseRecordId = rcaRecords[0].Case__c;
    Map<string,List<Shadow_Note__c>> res = new Map<string,List<Shadow_Note__c>>();
    Schema.DescribeFieldResult fieldResult = Shadow_Note__c.Note_Tag__c.getDescribe();
    List<Schema.PicklistEntry> ple =fieldResult.getPicklistValues();
    for (Schema.PicklistEntry a:ple ){
            res.put(a.value , new List<Shadow_Note__c>());
    List<LTNG_HTERCA_RightTagWrapper> shadowNotesTagList = new List<LTNG_HTERCA_RightTagWrapper>();
    List<Shadow_Note__c> allshadownotes = [SELECT Note__c,Note_Tag__c,Date_Time_Created_in_CSOne__c,CreatedBy_Name__c From Shadow_Note__c 
    WHERE Case__c =: caseRecordId AND Note_Tag__c != null 
    ORDER BY CreatedDate ASC];
    List<Case_History_Normalized__c> allnormalisedNotes = [SELECT Tags__c,IsTagged__c From Case_History_Normalized__c 
                                  WHERE Case__c =: caseRecordId AND IsTagged__c = TRUE ORDER BY CreatedDate ASC LIMIT 10];
    for(Shadow_Note__c sn: allshadownotes){
        List<String> noteTags = sn.Note_Tag__c.split(';');
        for(String tag: noteTags){
                List<Shadow_Note__c> notesList = res.get(tag);
                res.put(tag, notesList);
                system.debug('res is ++: ' + res);
    System.debug('the result is:' + JSON.serializePretty(res));
    return res;

the above controller is working for to display one object data i.e Shadow_Note__c but can anyone guide how to achieve for Case_History_Normalized__c object data, maybe a wrapper will work but can anyone guide me how to create a wrapper here to hold the fields data please