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
hramanihramani 

Compilation error for class

global without sharing class RecommendationEmailUpdate {

    @RemoteAction
    global static List<TargetX_SRMb__Recommendation__c> getRecommendations(String applicationId){
        List<TargetX_SRMb__Recommendation__c> recommendations = [Select Id, Mail__c, TargetX_SRMb__Application__c from TargetX_SRMb__Recommendation__c where TargetX_SRMb__Application__c = :applicationId];
        return recommendations;
    }
}

In this code, I'm getting the below error while compiling.
Error: Compile Error: Invalid identifier ' getRecommendations'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 4 column 56

Please help
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

I don't see anything visibly wrong with the above code. You might be getting this error because of copy & paste issue. You can get characters that are not visible in the code, particularly when you copy/paste code.

Delete and re-type all the characters. Re-typing the code (not using copy/paste for anything) fixes the issue.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi Hramani,

An error like these is usually thrown due to some minor errors (syntactical or spelling mistake) in code. Please follow link https://developer.salesforce.com/forums/?id=9060G000000MV8PQAW and check line numbers 8, 18 and 23 (in the corrected answer)for minor changes. So as far as your code is considered to please check for spelling mistakes in your query(Field name, object name) and other parts of the code like on line number 8 like matching contact instead of matching contacts.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi