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

Illegal assignment from LIST<User> to LIST<user>

Hello there,

I am facing this error on my DEV sandbox since 2 days however, the codebase is same among all my instances including Production.

Some of the pages on my sites display this error message:

Illegal assignment from LIST<User> to LIST<user>

The code to which I am getting this error message:

1. List<OAuth_Token__c> l = [SELECT, isAccess__c,, Owner__r.Id FROM OAuth_Token__c WHERE :serviceName AND isAccess__c = true];
2.         Set<Id> setUserIds = new Set<Id>();
3.        for(OAuth_Token__c t : l)
4.             setUserIds.add(t.owner__r.Id);
5.         if( !setUserIds.isEmpty() )
6.            List<User> result = [SELECT Id, Name FROM User WHERE Id IN: setUserIds ]; // error line
7.       else
8.            return null; 

The above error is on line no 6.

Thanks in advance.

Anoop yadavAnoop yadav

I think you have a controller in your instance with "User" Name Like below.

public class User {
    public User (){

No that't not the case Anoop. My codebase is constant among all my instances.
Anoop yadavAnoop yadav
Hi Pronow,

If this is not the case then try the below.

At Line 6 use List<Schema.User> instead of List<User>.
Thank you Anoop. That resolved my issue. Now the next big thing is, I have approx. 40 classes into which I will need to make this change.

This happened first time. Same code is working in all other instances however, DEV sandbox is the only one causing this problem.

Anyways, I also have logged a case to Salesforce. Hope, for the best that this problem should not get reproduced in Production.