Here's the SOQL I'm trying to run in my anonymous window, against the standard object:

List<Location> locs = [SELECT Id, Name FROM Location LIMIT 2];
for(Location l : locs)

Here's the error:

Line: 10, Column: 16
Illegal assignment from List<Location> to List<System.Location>

When i search my apex classes, I do not see a conflicing object already named Location

1 Answer 1


This error actually crops up any time FSL is enabled in an org. There is a System type called Location, and also a Schema type called Location. The latter is what you query for, but the former is the default assumed by the compiler, and it is unable to disambiguate.

The fix is to use Schema.Location in your type declarations when working with instances of the SObject.

List<Schema.Location> records = [SELECT Name FROM Location LIMIT 2];
  • 1
    Yup, we have Field Service Lighting enabled - the most poorly documented, poorly acquired-and-absorbed part of the otherwise impressive SF ecosystem
    – bkwdesign
    Nov 10, 2022 at 1:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .