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

Compile Error: Variable does not exist: Name at line 6 column 5
This is Simple Apex class
When iam creating account associated contact, Opportunity also create. This code Excuted successfully when it was created, after few days i used it with some modification then it shows the error like 'Variable does not exist: Name'
Public class Acc_Con_Opp_Create
{
public Account Creation()
{
Account acc=new Account();
acc.Name='Poel';
acc.NaicsDesc='uagtt';
insert acc;
Contact cc=new Contact();
cc.AccountId=acc.Id;
cc.LastName='John Paul';
insert cc;
Opportunity opp=new Opportunity();
opp.AccountId=acc.Id;
opp.StageName='Stage';
// Date d=Date.newinstance('2015,11,20');
opp.CloseDate=system.Today();
opp.Name='Apex created Opportunity';
insert opp;
return acc;
}
}
When iam creating account associated contact, Opportunity also create. This code Excuted successfully when it was created, after few days i used it with some modification then it shows the error like 'Variable does not exist: Name'
Public class Acc_Con_Opp_Create
{
public Account Creation()
{
Account acc=new Account();
acc.Name='Poel';
acc.NaicsDesc='uagtt';
insert acc;
Contact cc=new Contact();
cc.AccountId=acc.Id;
cc.LastName='John Paul';
insert cc;
Opportunity opp=new Opportunity();
opp.AccountId=acc.Id;
opp.StageName='Stage';
// Date d=Date.newinstance('2015,11,20');
opp.CloseDate=system.Today();
opp.Name='Apex created Opportunity';
insert opp;
return acc;
}
}
Hi Bhupati,
Account Name is standard field, I tried above code in my org and it works fine.
Please try again, if you still face some issue contact me.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
Skype: gaurav62990
If you problem is resolved, can you please mark it as solved.
Thanks,
Gaurav