You need to sign in to do that
Don't have an account?

error un test class?
Hi guys,
@isTest private with sharing class Loan { static testMethod void Loan() { Test.startTest(); // set up account Account acc = new Account(); acc.Name = 'Acme Account Test'; acc.Account_Type__c= 'Audio'; acc.Strategic_Segmentation__c= 'C - Small'; acc.Country__c= 'Spain'; insert acc; List<Contract> lstContract= new List<Contract>(); for(Integer iCount = 0; iCount < 20; iCount++) { Contract objContr = new Contract(); objContr.Account= acc.id; objContr.StartDate= Date.today(); objContr.ContractTerm= '11111'; objContr.CurrencyIsoCode= 'EUR'; objContr.Status= 'Borrador'; lstContract.Add(objContr); } insert lstContract; Test.StopTest(); } }
Error: Compile Error: Illegal assignment from Id to SOBJECT:Account at line 20 column 13 |
Any ideas??
Try adding this :
objContr.AccountId= acc.Id;
All Answers
Try: objContr.Account = acc;
instead of :objContr.Account = acc;.id
Method NameTotal Time (ms)MessageStack Trace
Got this error with this code??
I have tried what you recommended before but got an error with the Country ID, so I have added a few lines to it, but not sure if it is correct!!
Thanks for your help!
Try adding this :
objContr.AccountId= acc.Id;
You ROCK!!!!!!
:))
Thanks!!