You need to sign in to do that
Don't have an account?
Nitish Kulkarni
Invalid constructor syntax, name=value pairs can only be used for SObjects: contact
// Create a list of contacts 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()}; // Bulk insert all contacts with one DML call Database.SaveResult[] srList = Database.insert(conList, false); // Iterate through each returned result for (Database.SaveResult sr : srList) { if (sr.isSuccess()) { // Operation was successful, so get the ID of the record that was processed System.debug('Successfully inserted contact. Contact ID: ' + sr.getId()); } else { // Operation failed, so get all errors 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()); } } }I am getting invalid constructor syntax error in anonymous apex. this code is from trailhead in which database method is used.
Just check if you have an apex class named Contact.
If so delete that class or rename it.
All Answers
Just check if you have an apex class named Contact.
If so delete that class or rename it.
Was it fixed? What issue your are getting exactly?