You need to sign in to do that
Don't have an account?
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 OAuth_Service__r.name, isAccess__c, Owner__r.name, Owner__r.Id FROM OAuth_Token__c WHERE OAuth_Service__r.name= :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.
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 OAuth_Service__r.name, isAccess__c, Owner__r.name, Owner__r.Id FROM OAuth_Token__c WHERE OAuth_Service__r.name= :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.
I think you have a controller in your instance with "User" Name Like below.
If this is not the case then try the below.
At Line 6 use List<Schema.User> instead of List<User>.
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.