+ Start a Discussion
sowmya thotthadisowmya thotthadi 

AccountContactOppurtunitycon Compile Error: Variable does not exist: id at line 10 column 32

public class AccountContactOppurtunitycon {
       
   public AccountContactOppurtunitycon()
   {
    accountid = new set<id>();
    for(OpportunityContactRole contactRole : [select ContactId , Contact.Name, opportunityId ,opportunity.Name ,opportunity.Amount, opportunity.Account.Name,Opportunity.AccountId  from OpportunityContactRole]){
     accountid.add(ContactRole.Opportunity.AccountId);
     for(id idrecord :accountid){
        InnerClass ic=new InnerClass();
        ic.opporidtunityList = id;
      }
   }
 }
 public class InnerClass{
      Public opportunity opportunityList{get; set;}
      Public list<OpportunityContactRole> contactRole{get;set;} 
    }
     
Brahmaiah GantaBrahmaiah Ganta
Hi Sowmay,
we are gettting error with this line  " ic.opporidtunityList = id;" replace that line with "  ic.opporidtunityList = idrecord;"  because here "idrecord" is variable and one more thing declare set properly Like set<id> accountid = new set<id>()'

Please Let me Known we have any queries.
 
sowmya thotthadisowmya thotthadi
AccountContactOppurtunitycon Compile Error: Variable does not exist: at line 10 column 39
   accountid.add(ContactRole.Opportunity.AccountId);
     for(id idrecord :accountid){
        InnerClass ic=new InnerClass();
         ic.opportunityList= idrecord.;
      }
Brahmaiah GantaBrahmaiah Ganta
Please remove the dot(.) before semicolone(;)
Pradeep SinghPradeep Singh
public AccountContactOppurtunitycon()
   {
    accountid = new set<id>();
     List<InnerClass> innerclassList = new List<InnerClass>();
    for(OpportunityContactRole contactRole : [select ContactId , Contact.Name, opportunityId ,opportunity.Name ,opportunity.Amount, opportunity.Account.Name,Opportunity.AccountId  from OpportunityContactRole]){
     accountid.add(ContactRole.Opportunity.AccountId);     
   }
   for(id idrecord :accountid){
        InnerClass ic=new InnerClass(idrecord);
        innerclassList.add(ic);
      }
}
 
 public class InnerClass{
      Public id opportunityId{get; set;}
      Public list<OpportunityContactRole> contactRole{get;set;} 
      public InnerClass(Id opprecordId){
              opportunityId = opprecordId ;
       }
    }
Pradeep SinghPradeep Singh
You can use map here if you want to just map accountid with OpportunityContactRole
Map<id,List<OpportunityContactRole>> accountid ;
public AccountContactOppurtunitycon()
   {
    accountid = new Map<id,List<OpportunityContactRole>>();
     List<InnerClass> innerclassList = new List<InnerClass>();
    for(OpportunityContactRole contactRole : [select ContactId , Contact.Name, opportunityId ,opportunity.Name ,opportunity.Amount, opportunity.Account.Name,Opportunity.AccountId  from OpportunityContactRole]){
if(!accountid.containskey(ContactRole.Opportunity.AccountId)) {
   accountid.put(ContactRole.Opportunity.AccountId,new List{ContactRole});
}    
 else{
    accountid.get(ContactRole.Opportunity.AccountId).add(ContactRole);
}    
   }
}
Pradeep SinghPradeep Singh
public class AccountContactOppurtunitycon {
  Map<id,List<OpportunityContactRole>> accountid ;
 public AccountContactOppurtunitycon()
   {
    accountid = new Map<id,List<OpportunityContactRole>>();
    for(OpportunityContactRole contactRole : [select ContactId , Contact.Name, opportunityId ,opportunity.Name ,opportunity.Amount, opportunity.Account.Name,Opportunity.AccountId  from OpportunityContactRole]){
      if(!accountid.containskey(ContactRole.Opportunity.AccountId)) {
         accountid.put(ContactRole.Opportunity.AccountId,new List<OpportunityContactRole>{ContactRole});
      }    
      else{
        accountid.get(ContactRole.Opportunity.AccountId).add(ContactRole);


}
}
}
}    

 
 
Pradeep SinghPradeep Singh
If this solves your issue, please mark it as best answer.
 
Pradeep SinghPradeep Singh
Hi,
Given code is of 17 lines. How the error is at 27..? If you have added something to this code, then you must post code as well. Also you should ask question about what you want (what is you requirement/end result) and what help you need.
sowmya thotthadisowmya thotthadi
i had solved thank u
sowmya thotthadisowmya thotthadi
but i want dont want to have duplicate in my table soo i have taken SET in that i have LIST values

 public AccountContactOppurtunitycon() {
    accountid = new set<id>();
     List<InnerClass> innerclassList = new List<InnerClass>();
    for(OpportunityContactRole contactRole : [select ContactId , Contact.Name, opportunityId ,opportunity.Name ,opportunity.Amount, opportunity.Account.Name,Opportunity.AccountId  from OpportunityContactRole]){
     accountid.add(ContactRole.Opportunity.AccountId);     
   }
   for(id idrecord :accountid){
        InnerClass ic=new InnerClass(idrecord);
        innerclassList.add(ic);
          System.debug('@@@@'+innerclassList);
       
         {
           
         }
      }     
}
 
 public class InnerClass{
      Public id opportunityId{get; set;}
      Public list<OpportunityContactRole> contactRole{get;set;} 
      public InnerClass(Id opprecordId , ContactId contact){
              opportunityId = opprecordId ;
              contactRole = contact ;
       }
    }