You need to sign in to do that
Don't have an account?
Danny Hartley
unexpected token '<' in trailhead
I am receiving this error:
"Line: 1, Column: 5
unexpected token: '<'"
when executing this code:
List<Contact> conList = new List<Contact> {
new Contact(FirstName='Joe', LastName='Smith', Department='Finance'),
new Contact(FirstName='Kathy', LastName='Smith', Department='Technology'),
new Contact(FirstName='Caroline', LastName='Roth', Department='Finance'),
new Contact();
}
Database.SaveResult[] srList = Database.insert(conList, false);
for (Database.SaveResult sr : srList) {
if(sr.isSuccess()) {
System.debug('Successfully inserted contact. Contact ID: ' + sr.getID());
} else{
for(Database.Error err : sr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Contact fields that affected this error: ' + err.getFields());
}
}
}
in the execute anonymous window in the developer console (this is a trailhead exercise). Thanks in advance for any help.
"Line: 1, Column: 5
unexpected token: '<'"
when executing this code:
List<Contact> conList = new List<Contact> {
new Contact(FirstName='Joe', LastName='Smith', Department='Finance'),
new Contact(FirstName='Kathy', LastName='Smith', Department='Technology'),
new Contact(FirstName='Caroline', LastName='Roth', Department='Finance'),
new Contact();
}
Database.SaveResult[] srList = Database.insert(conList, false);
for (Database.SaveResult sr : srList) {
if(sr.isSuccess()) {
System.debug('Successfully inserted contact. Contact ID: ' + sr.getID());
} else{
for(Database.Error err : sr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Contact fields that affected this error: ' + err.getFields());
}
}
}
in the execute anonymous window in the developer console (this is a trailhead exercise). Thanks in advance for any help.
Not sure if this is the only issue, but looks like the very first semi-colon is in the wrong place. Try the following:
I'm also receiving a similiar error in ananymous window.
Can someone please help me figure out what doing wrong? Below is my code
Thanks
Syntax is corect > this is working just changed object name from your code .Try onemore time .
List<Account> listitem= [SELECT Id, Name FROM
Account ];
Thanks & Regards
Rahul Jain
You have the semicolon in wrong place.
You can try the below code.
In case you find any other issue please mention.
If you find your Solution than mark as this as a best answer.
Thanks and Regards
Suraj Tripathi.