0 votes
4 views
by

I'* very new to Salesforce development and I'* writing this class to return some queries from the Location_Tracing_c:

public class CTLocationTracingController{
    
    /**Get last 30 days visitors 
    //@return List<Location_Tracing_c> 
    */
    public static List<Location_Tracing_c> getVisitors(String locationId){
        return [SELECT Id, Person__c, Location__c, Visit_Date__c, Person__r.Health_Status__c, Person__r.Token__c 
                FROM Location_Tracing__c 
                WHERE Id =: locationId 
                ORDER BY Visit_Date__c DESC] ;
    }

    /**Get all location ids for visitors 
    //@return List<Location_Tracing_c> 
    */
    public static List<Location_Tracing_c> getLocationsByPersonIds(Set<Id> personIds){
        return [SELECT Id, Person__c, Location__c 
                FROM Location_Tracing__c 
                WHERE Person__c IN :personIds 
                AND Visit_Date__c = LAST_N_DAYS:10] ;
    }

    /**Get all visitor ids for locations 
    //@return List<Location_Tracing_c> 
    */
    public static List<Location_Tracing_c> getLocationsByLocationsIds(Set<Id> locationIds){
        return [SELECT Id, Name, Person__c, Location__c, Visit_Date__c 
                FROM Location_Tracing__c 
                WHERE Location__c IN: locationIds 
                AND Visit_Date__c = LAST_N_DAYS:10
                AND Person__r.Health_Status__c = 'Green'] ;
        }
    
}

But I'* getting this error basically for all my methods :

Invalid type: Location_Tracing_c (26:44)                                            
Illegal conversion from List<Location_Tracing__c> to List<Location_Tracing_c> (17:9)

I'* not sure what i'* doing wrong. Any help is highly appreciated.

1 Answer

0 votes
by
 
Best answer

Welcome to Salesforce, and welcome to the salesforce stack exchange!

Your issue here is basically a spelling/keying error. The return value for all of your methods is "Location_Tracing_c", which only has one underscore between "Tracing" and "c". Custom objects always end with "__c", which has two underscores followed by a "c".

The SOQL queries however are correct, having both underscores. So thus the compiler thinks that you're trying to convert a list of __c to a list of _c, which is invalid. In addition, there are no apex types of the _c variety, so you're getting the "Invalid Type" error.

Welcome to Memory Exceeded, where you can ask questions and receive answers from other members of the community.
You can donate any amount for Orphans village using following QR Code.
...