[SalesForce] Execute anonymous Unexpected Token

I'm trying to insert a record into a custom object via Execute Anonymous and get Line 2, Column 19 Unexpected Token 'InvA' This is sample code from Trailhead and it uses the Account object as an example and it works. When I try to point to my Custom Object (InvoiceAccount) it errors. I'm using the object's API Name.

// Create the InvoiceAccount sObject 
InvoiceAccount__c InvA = new InvoiceAccount__c(Name='Acme', Account_Owner_Email__c='Tiger5K@outlook.com', Account_Owner_Name__c='Sabrina Smith';
// Insert the InvoiceAccount by using DML
insert InvA;

Best Answer

You are missing a closing parenthesis.

InvoiceAccount__c InvA = new InvoiceAccount__c(Name='Acme', Account_Owner_Email__c='Tiger5K@outlook.com', Account_Owner_Name__c='Sabrina Smith';

should be

InvoiceAccount__c InvA = new InvoiceAccount__c(Name='Acme', Account_Owner_Email__c='Tiger5K@outlook.com', Account_Owner_Name__c='Sabrina Smith');
Related Topic