You need to sign in to do that
Don't have an account?
Timothy Smith
Error: 'Field does not exist: AccountId on Contact'
In my test class the error is telling me that AccountId does not exist on Contact. Is there another name I should be using? Any other suggestions regarding my code are welcomed. Thank you
@isTest private class ContactDNCOpportunityTest { private static testMethod void testCloseOpps(){ //Create Account Account newAcc = FlowTestUtils.createHouseholdAccount(); insert newAcc; //Create Contacts List<Contact> conList = new List<Contact> { new Contact(FirstName='test1',LastName='tester',AccoutId = newAcc.Id, Email = 'test1@testing.com', Phone = 1234567891, Phone_Status__c = True, Work_Phone_Status__c = False, Mobile_Phone_Status__c = False), //Has Phone Number DNC is Checked new Contact(FirstName='test2',LastName='tester',AccoutId = newAcc.Id, Email = 'test2@testing.com', Phone_Status__c = False,Work_Phone_Status__c = False, Mobile_Phone_Status__c = False), //Blank No Numbers new Contact(FirstName='test3',LastName='tester',AccoutId = newAcc.Id, Email = 'test3@testing.com', Normalized_Work_Phone__c = 1234567891,Phone_Status__c = False, Work_Phone_Status__c = False, Mobile_Phone_Status__c = False), // Has Worknumber DNC not checked new Contact(FirstName='test4',LastName='tester',AccoutId = newAcc.Id, Email = 'test4@testing.com', Phone = 1234567891, Phone_Status__c = False, Work_Phone_Status__c = False, Mobile_Phone_Status__c = False), //Has Phone Number DNC not checked new Contact(FirstName='test5',LastName='tester',AccoutId = newAcc.Id, Email = 'test5@testing.com', Normalized_Mobile_Phone__c = 1234567891, Mobile_Phone_Status__c = True, Phone_Status__c = False,Work_Phone_Status__c = False), //Has mobile number DNC is checked new Contact(FirstName='test6',LastName='tester',AccoutId = newAcc.Id, Email = 'test6@testing.com', Normalized_Work_Phone__c = 1234567891, Phone_Status__c = False, Work_Phone_Status__c = True,Mobile_Phone_Status__c = False) //Has Worknumber DNC is checked }; insert conList; Test.startTest(); Opportunity opptest1 = new Opportunity(Name = 'Opp1', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Primary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test1']); insert opptest1; Test.stopTest(); System.assertEquals('Closed', opptest1.StageName); Test.startTest(); Opportunity opptest2 = new Opportunity(Name = 'Opp2', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Primary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test2']); insert opptest2; Test.stopTest(); System.assertEquals('Closed', opptest2.StageName); Test.startTest(); Opportunity opptest3 = new Opportunity(Name = 'Opp3', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Primary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test3']); insert opptest3; Test.stopTest(); System.assertEquals('Closed', opptest3.StageName); Test.startTest(); Opportunity opptest4 = new Opportunity(Name = 'Opp4', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Secondary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test4']); insert opptest4; Test.stopTest(); System.assertNotEquals('Closed', opptest4.StageName); Test.startTest(); Opportunity opptest5 = new Opportunity(Name = 'Opp5', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Secondary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test5']); insert opptest5; Test.stopTest(); System.assertEquals('Closed', opptest5.StageName); Test.startTest(); Opportunity opptest6 = new Opportunity(Name = 'Opp6', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Secondary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test6']); insert opptest6; Test.stopTest(); System.assertEquals('Closed', opptest6.StageName); Test.startTest(); Opportunity opptest7 = new Opportunity(Name = 'Opp7', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today()); insert opptest7; Test.stopTest(); System.assertEquals('Closed', opptest7.StageName); }; }
There's Spelling Mistake In Your Code 'AccoutId '
Correction = 'AccountId'
Please Mark It As Best Answer If It Helps Thank You!