You need to sign in to do that
Don't have an account?
Osiris77706
Error: Compile Error: Invalid type: Schema.Location
Hello,
I'm modifying an existing APEX class to search through existing location objects to determine if a new one needs to be created in a particular situation. When I try to save the new code, I get the following error : Error: Compile Error: Invalid type: Schema.Location at line 189 column 34. My first guess based on research was that i must have the wrong name for the location object. Note here that i am using the standard SFDC Location object. As far as i can tell, the name is simply "Location" no more / no less, According to SFDC documentation and Our Enterprise WSDL. Second guess is that myself or whatever user is 'compiling' the code on save must not have permission to the Location object. I double checked that myself and API User both have access, they do. I'm at a brick wall here. I've simplified to code on the line in question to simply: "List<Location> locList = [Select id from Location ];" and I’m still getting the error. I then switched to the following:
1) List<Location> locList = new List<Location>();
2) locList = [Select id from Location];
I tried splitting the statement into two lines in order to better pinpoint the issue, in this situation I get the error on the second line, the query line, like I can create a list of locations, but I cannot populate it with a very basic select all query.
Does anyone have any idea on what could be going on here?
Thanks!
I'm modifying an existing APEX class to search through existing location objects to determine if a new one needs to be created in a particular situation. When I try to save the new code, I get the following error : Error: Compile Error: Invalid type: Schema.Location at line 189 column 34. My first guess based on research was that i must have the wrong name for the location object. Note here that i am using the standard SFDC Location object. As far as i can tell, the name is simply "Location" no more / no less, According to SFDC documentation and Our Enterprise WSDL. Second guess is that myself or whatever user is 'compiling' the code on save must not have permission to the Location object. I double checked that myself and API User both have access, they do. I'm at a brick wall here. I've simplified to code on the line in question to simply: "List<Location> locList = [Select id from Location ];" and I’m still getting the error. I then switched to the following:
1) List<Location> locList = new List<Location>();
2) locList = [Select id from Location];
I tried splitting the statement into two lines in order to better pinpoint the issue, in this situation I get the error on the second line, the query line, like I can create a list of locations, but I cannot populate it with a very basic select all query.
Does anyone have any idea on what could be going on here?
Thanks!
So, I noticed that the API version attached to the trigger was out of date, so I went ahead and changed it from like version 36 to 45. This changed the error I was getting. Now it was saying that I was doing an illegal comparison between type Location and system.Location. I then tried all permutations of system.Location in my query and none of them worked. On a whim I tried using the keyword schema, as in schema.Location in the definition of the list and it worked.
Just for some context we just installed Field Service Lightning (FSL) which is a package directly from SFDC. This package comes with a Location and Address Object. I believe that since these objects are directly from SFDC and not custom, the system did not add the __c and now requires schema.object.
So just to be totally clear, the right way to write the code, in my situation was like this:
1) List<schema.Location> locList = new List<Location>();
2) locList = [Select id from Location];
This seems to be due to the fact that there is a System.Location that is assumed by the system when you just type location.