You need to sign in to do that
Don't have an account?
Depton
Variable does not exist: Account at line....
Hi,
I got this error trying to create this test class:
@isTest private with sharing class Opportunity { static testMethod void Opportunity() { Test.startTest(); List<Opportunity> lstOp= new List<Opportunity>(); for(Integer iCount = 0; iCount < 20; iCount++) { Opportunity objOpp = new Opportunity(); objOpp .Account= 'Test'; objOpp .Name= '11111'; objOpp .StageName= 'Visit'; objOpp .CloseDate= Date.today(); lstOp.Add(objOpp); } insert lstOp; Test.StopTest(); } }
I have tried
Account
AccountName
Account__c
Account__r
Account__r.id
And always the same errror??
Thank you
First give the test values for account
Then for opportunity test values give
opp.accountid=acc.id
All Answers
First give the test values for account
Then for opportunity test values give
opp.accountid=acc.id
Ofcourse!!
Thank you!!
:)
Opportunity record has a reference of Account, which means it has the ID of the Account Record not the name
First try to create a Account and then use its ID .
Account acc = new Account(Name='Test Account');
Insert acc;
Error: Compile Error: Invalid type: acccount. at line 10 column 9
??
Thank you
just give AccountId
dont give it as Account__r
Thank you,
I got the error now inthis line
acccount. Name= 'Spain';
Error: Compile Error: Invalid type: acccount. at line 10 column 9
Take ou the space
give
Account.Name
Still getting an error in the line: objOpp.Account= a.id;
But I have modified the order and I got the error in all the objOpp
objOpp.Account= a.id;
objOpp.StageName= 'Visit';
objOpp.CloseDate= Date.today();
objOpp.Name= '11111';
Error: Compile Error: Variable does not exist:
The Account field on an opportunity is a reference to an object. You are providing the id, so you need to change the field to AccountId, e.g.
Thank you Bob!!
I am not marking yours as the Solution because I did before!
And thank you all for the explanations!!:)
Hah - no problem. Mine wasn't exactly a huge contribution, just the final nudge.