You need to sign in to do that
Don't have an account?
Sainath 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
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
I have two objects
- Shadow_Note__c
- Case_History_Normalized__c
@AuraEnabled(Cacheable=true) 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){ caseRecordId.add(rca.Case__c); }*/ 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){ if(res.containsKey(tag)){ List<Shadow_Note__c> notesList = res.get(tag); notesList.add(sn); 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