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
Kiran PandiyanKiran Pandiyan 

Why am I getting this error ?Please look at the Attachment and Description

User-added image
This code is a sample code in Trailhead to be run on Anonymous window. I get below error always. I tried removing the space and retyping those words. But still I'm getting this error in same or someother line. Let me know a solution for this problem.

"Error: Compile Error: Invalid identifier '    BillingCity'. 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), '$', '_', or unicode characters from U+0080 to U+FFFE. at line 5 column 1"

Best Answer chosen by Kiran Pandiyan
DeveloperSudDeveloperSud
Hi Kiran,

Your code looks good and I copy your code and ran it in my developer org's anonymous window.I did not get any error.Probably the code is getting any invisible character for you while copy-paste ,so it is giving the error.I will sugget you to delete the previous code and copy the code again from here and run it in anonymous window.Check if that works.

All Answers

AvaneeshAvaneesh
Hi Kiran ,

Can you show me your program 
Kiran PandiyanKiran Pandiyan
Account acct=new Account(
    Name='SFDC Computing',
    Phone='(415)555-1212',
    NumberOfEmployees=50,
    BillingCity='San Francisco');
insert acct;

// Once the account is inserted, the sObject will be
// populated with an ID.
// Get this ID.
ID acctID = acct.ID;

// Add a contact to this account.
Contact con = new Contact(
    FirstName='Carol',
    LastName='Ruiz',
    Phone='(415)555-1212',
    Department='Wingo',
    AccountId=acctID);
insert con;

// Add account with no contact
Account acct2 = new Account(
    Name='The SFDC Query Man',
    Phone='(310)555-1213',
    NumberOfEmployees=50,
    BillingCity='Los Angeles',
    Description='Expert in wing technologies.');
insert acct2;

This is the exact cod, I copy pasted. Thanks 
AvaneeshAvaneesh
Hi Kiran ,

if you need to run it on Anonymous window. then don't use apex class 
1-open your developer console
2-use control+e to open Anonymous window 
3-then paste your code 
enjoy---
if you have any question then give a comment 
please select as best answer if this is helpful
Thank you 
Avaneesh Singh
AvaneeshAvaneesh
Let me know if you have still any problem .
DeveloperSudDeveloperSud
Hi Kiran,

Your code looks good and I copy your code and ran it in my developer org's anonymous window.I did not get any error.Probably the code is getting any invisible character for you while copy-paste ,so it is giving the error.I will sugget you to delete the previous code and copy the code again from here and run it in anonymous window.Check if that works.
This was selected as the best answer
Kiran PandiyanKiran Pandiyan
 User-added image
Hi first time I tried just copy pasting and I got this error.
User-added image
The above screenshot is second time, I removed the space in first line and I ran. It keeps shifting to next line as I remove space fro each line.
AvaneeshAvaneesh
Hii Kiran 

If i am right than it is formatting error. don't copy paste your code and type your code in annonymos window and hit execute button .
i don't think there is any problem in your code 

Thank you
Avaneesh Singh
AvaneeshAvaneesh
User-added image

it work's fine in my org don't copy paste try to write your code and then hit excute window . it will work fine don't forget to chose best answer 
Thank you
Avaneesh Singh