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
guest1231231guest1231231 

List controllers are not supported for Task

Is there a workaround for "List controllers are not supported for Task"?

 

Thanks

 

public class ActivityHistorySetConExt {

        //ApexPages.StandardSetController must be instantiated for standard list controllers
 
        public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      	[select subject, whoid, whatid, accountid, ownerid, activitydate, description 
                      	from Task 
						order by activitydate desc
						limit 1000]
                      )
				);
            }
            //setCon.SetPageSize(5);
            return setCon;
        }
        set;
    }
    
    // Initialize setCon and return a list of records  
    
    public List<Task> getTasks() {
         return (List<Task>) setCon.getRecords();
    }
    
    // returns the next page of records
 	public void first() {
 		setCon.first();
 	}
 	
 	// returns the next page of records
 	public void last() {
 		setCon.last();
 	}
    
    // indicates whether there are more records before the current page set.
	public Boolean hasPrevious {
		get {
			return setCon.getHasPrevious();
		}
		set;
	}
	
	// returns the previous page of records
 	public void previous() {
 		setCon.previous();
 	}
    
    // indicates whether there are more records after the current page set.
	public Boolean hasNext {
		get {
			return setCon.getHasNext();
		}
		set;
	}
	
	// returns the next page of records
 	public void next() {
 		setCon.next();
 	}
    
}

 

Jeremy_nJeremy_n

You can always make a custom controller that does what you need. I've done this before for Tasks.

 

One thing I ran into in dealing with Tasks is that you can't use ActivityDate to order your query results; this is mentioned in a footnote in the Developers' Guide, and if I'd seen it sooner, it would have saved hours of frustration. This problem may be cleared up soon, I don't know.

 

Let us know if you need tips on how to do the controller code.

 

Jeremy