function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bhupathi YadavBhupathi Yadav 

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;
      
    }
  }
GauravGargGauravGarg

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

GauravGargGauravGarg
Hi Bhupathi,

If you problem is resolved, can you please mark it as solved. 

Thanks,
Gaurav