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
Shephali SwarnkarShephali Swarnkar 

Unexpected Error

I am getting the following Error:
    [Error] Error: agent_task Compile Error: Illegal assignment from List<Task> to List<Task> at line 9 column 6
Please help me to figure it out:

public class task_list
 {   
    public String str{get;set;}
    public list<task> tasklist{get;set;}    
 public task_list()
 {
       str=UserInfo.getname();
     tasklist =[Select subject,Priority, status, ActivityDate,CreatedBy.Name,Owner.Name,Who.Name,Description, ReminderDateTime from task  where Owner.name= :str];
 } 
}
Best Answer chosen by Shephali Swarnkar
Shephali SwarnkarShephali Swarnkar
Hi Alex and Manoj,
              Thanks For Reply.I fixed the error i got 

In my DE somewhere I have created a class named "task". Thats why the compiler wasnot able to understand that it is standard Object "Task" or the class created by Me. I renamed that class, it is working Now.

Thanks Shephali
 

All Answers

Alexander TsitsuraAlexander Tsitsura
Hi Shephali

I succesfully save you class in my dev org, can you try save file throught salesforce(Setup -> Develep-> Apex Classes -> New). 

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.

Thanks,
Alex
ManojjenaManojjena
Hi Shephali,
Try with below code
public class task_list{   
    public String str{get;set;}
    public list<task> Tasklist{get;set;}    
    public task_list(){
       str=UserInfo.getname();
       tasklist=new List<Task>();
       if(str != null)
       tasklist =[Select subject,Priority, status, ActivityDate,CreatedBy.Name,Owner.Name,Who.Name,Description, ReminderDateTime from task  where Owner.name= :str];
 } 
}

When exactly you are getting this error ?
Let me know if it helps !!
Thanks
Manoj

 
Shephali SwarnkarShephali Swarnkar
Hi Alex and Manoj,
              Thanks For Reply.I fixed the error i got 

In my DE somewhere I have created a class named "task". Thats why the compiler wasnot able to understand that it is standard Object "Task" or the class created by Me. I renamed that class, it is working Now.

Thanks Shephali
 
This was selected as the best answer