function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yash mehta 12yash mehta 12 

Can anyone tell me to write this queries as it can show all activity in one page in decending order and code which i attached is absolutly correct

public class LightningActivityHistory{
    Id sObjectname= ApexPages.currentPage().getParameters().get('Id');
    
    public list<Task> tasklist{get;set;}
    public list<Task>LeadTask{get;set;}
    public Id LeadId{get;set;}
    public LightningActivityHistory(){
        
        if(sObjectname !=null )
            tasklist= [select id,Status,ActivityDate,Subject,Who.Name,What.Name,Description,LastModifiedDate,Owner.Name,Type FROM Task WHERE WhatID=:sObjectname OR whoId=:sObjectname ORDER BY ActivityDate DESC];
        for(Lead led :[SELECT id,Name,(select id,Status,ActivityDate,Subject,Who.Name,What.Name,Description,LastModifiedDate,Owner.Name,Type FROM Tasks) FROM Lead WHERE Account__c =: sobjectname]){
            LeadId = led.id;
        }
        
        LeadTask =[select id,Status,ActivityDate,Subject,Who.Name,What.Name,Description,LastModifiedDate,Owner.Name,Type FROM Task WHERE whoId=:LeadId ORDER BY ActivityDate DESC];
        
    }
    public PageReference cancel() {
        PageReference ldPage = new PageReference('/'+sObjectname);
        ldPage.setRedirect(true);
        return ldPage;
    }
}
Raj VakatiRaj Vakati
public class LightningActivityHistory{
    Id sObjectname= ApexPages.currentPage().getParameters().get('Id');
    
    public list<Task> tasklist{get;set;}
    public list<Task>LeadTask{get;set;}
    public Id LeadId{get;set;}
    public LightningActivityHistory(){
        if(sObjectname !=null )
            tasklist= [select id,Status,ActivityDate,Subject,Who.Name,What.Name,Description,
                       LastModifiedDate,Owner.Name,Type FROM Task WHERE WhatID=:sObjectname OR whoId=:sObjectname ORDER BY ActivityDate DESC];
        LeadId = [SELECT id,Name FROM Lead WHERE Account__c =:sobjectname].id ;
        
        
        
        LeadTask =[select id,Status,ActivityDate,Subject,Who.Name,What.Name,Description,LastModifiedDate,Owner.Name,Type FROM Task WHERE whoId=:LeadId ORDER BY ActivityDate DESC];
        
    }
    public PageReference cancel() {
        PageReference ldPage = new PageReference('/'+sObjectname);
        ldPage.setRedirect(true);
        return ldPage;
    }
}
yash mehta 12yash mehta 12
See I am not getting dates for both account and Leads all togeather in descending orderUser-added image