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
Ola BamideleOla Bamidele 

Does any one know why this code isnt saving?

Hi everyone, 

I have this code for be able to display leads on a map with the distance away from you. 

However for me, it isnt savibg for some reason that I cant see, can anyone see what i am doing wrong please?

This is my code:
 
public with sharing class LeadVisualiserSSController {
    @AuraEnabled
    public static List<Lead> getLeads() {
        return [
            SELECT Id, Name, Latitude, Longitude
            FROM Lead
            WHERE OwnerId = :UserInfo.getUserId() AND Latitude != NULL AND Longitude != NULL
        ];
    }

    @AuraEnabled
    public static User getUserInfo() {
        return [
            SELECT Id, Name, Base_Location__Latitude__s, Base_Location__Longitude__s
            FROM User
            WHERE Id = :UserInfo.getUserId()
        ];
    }
}

Thanks very much
Hemant_SoniHemant_Soni
Hi Ola Bamidele,
I have tried to save this code in my developer org and is saved without any issue.
please let us know what issue you are facing.
Thanks
Hemant
Ola BamideleOla Bamidele
Hi Hemant_Soni, 

The error that i am getting is:
SELECT Id, Name, Base_Location__Latitude__s, Base_Location__Longitude__s
                             ^
ERROR at Row:2:Column:30
No such column 'Base_Location__Latitude__s' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

I have tried changing the __s to __c but still isnt working, do you know why by any chance?

Thanks very much.
 
Hemant_SoniHemant_Soni
This error indicate that "Base_Location__Latitude__c, Base_Location__Longitude__c" these fields are not available on User Object. So please try to make sure you have these field on User object.
Thanks
Ola BamideleOla Bamidele
Hi Hemant_Soni, 

The field name in Salesforce is "Base_location__c" so i changed it to that but still getting an error saying 
 
SELECT Id, Name, Base_Location__c
                             ^
ERROR at Row:2:Column:30
No such column 'Base_Location__c' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.


Do you know why this is? THanks very much for the suggestions


 
Hemant_SoniHemant_Soni

Did you provide all necessary Permission to this field may this field doesn't have sufficient access.Please Check.
Thanks

Jonathan AndersonJonathan Anderson
Hi Ola,  can you post up the new code, as well as the API name and the label name of the Base_Location__c field please?

This might help people fix your problem faster.
 
Ola BamideleOla Bamidele
Hi Hemant_Soni, 

All necessary Permission are enable so the field must have sufficient access. So it very weird that your one is working by my one isnt 

Thanks 

 
Ola BamideleOla Bamidele
Hi Jonathan Anderson, 

My new code is the same as any changes I have made has not worked unfortunately:
public with sharing class LeadVisualiserSSController {
    @AuraEnabled
    public static List<Lead> getLeads() {
        return [
            SELECT Id, Name, Latitude, Longitude
            FROM Lead
            WHERE OwnerId = :UserInfo.getUserId() AND Latitude != NULL AND Longitude != NULL
        ];
    }

    @AuraEnabled
    public static User getUserInfo() {
        return [
            SELECT Id, Name, Base_Location__Latitude__s, Base_Location__Longitude__s
            FROM User
            WHERE Id = :UserInfo.getUserId()
        ];
    }
}


Also, my API Name is:Base_location__c and the field label is Base location. 

Thanks for the response
Jonathan AndersonJonathan Anderson
I meant please post up the code you are trying to save! You can copy and paste it from where you are typing it in.

 
Ola BamideleOla Bamidele
Hi Jonathan Anderson, 

This is the code that I am trying to save. I am trying to save it into my Salesforce developer console and its not saving. Has that cleared it up more?

Thanks
Jonathan AndersonJonathan Anderson
No, I mean I need to see the code that gave you the error: "No such column 'Base_Location__c' on entity 'User'."

It isn't possible to help fix the problem that gave you that error without seeing the code that mentions Base_Location__c - does that make sense?