You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Display fields from two different objects in a single column of a datatable?
Hello, so I try to create a datatable component that displays tasks and events of a contact in a single table.
For now I created a code that shows both tasks and events but in two seperated areas, but I really do not know what approach I should take to combine the results of these two. Maybe you could help me with this topic. So my Controller now is like that:
task1 ActivityDate task2 ActivityDate event1 ActivityDate task3 ActivityDate event2 ActivityDate event3 ActivityDate
For now I created a code that shows both tasks and events but in two seperated areas, but I really do not know what approach I should take to combine the results of these two. Maybe you could help me with this topic. So my Controller now is like that:
public class ApexActivityWrapper { @AuraEnabled public static wrapper method1 (){ string userId = UserInfo.getUserId(); List<Task> getTask = [SELECT Subject, ActivityDate FROM Task WHERE OwnerId=:userId ORDER BY ActivityDate]; List<Event> getEvent = [SELECT Subject, ActivityDate FROM Event WHERE OwnerId=:userId ORDER BY ActivityDate]; wrapper wrp = new wrapper(); wrp.taskList = new List<Task>(getTask); wrp.eventList = new List<Event>(getEvent); return wrp; } public class wrapper{ @AuraEnabled public List<Task> taskList ; @AuraEnabled public List <Event> eventList; } }
Find a detailed example in this link How to display multiple object records in a single lightning data table of Salesforce (https://www.codekiat.com/2022/11/display-multiple-object-records-in-single-lightning-data-table-salesforce.html)