0

Public class CampaignmemberSa{

public lead l{get;set;}
public List<Innerclass> wraplist{get;set;}
public  CampaignmemberSa(){
wraplist= new List<Innerclass>();
}
Public void campaignonchange(){
for(Campaignmember cm:[select id,lead.Status,lead.Company,lead.FirstName,lead.lastName,lead.City,lead.State,lead.Country,lead.leadSource,Contact.status__c,Contact.Company__c,Contact.FirstName,
  Contact.lastName,Contact.City__c,Contact.State__c,Contact.Country__c,Contact.leadSource from Campaignmember where  CampaignId =: lead.Campaign__c]){
   wraplist.add(new Innerclass(cm));
}
}   

Public class Innerclass{
       Public CampaignMember cm{get;set;}
       Public String Status{get;set;}
       Public String Company{get;set;}
       Public String FirstName{get;set;}
       public String lastName {get; set;}
       Public String City{get;set;}
       Public String State{get;set;}
       Public String Country{get;set;}
       public String leadSource {get;set;}
           Public Innerclass(CampaignMember cm){

              this.cm = cm;
              if(cm.Lead.Id != null){
                  this.Status = cm.Lead.Status != null ? cm.Lead.Status : '';
              }else if(cm.Contact.Id != null){
                  this.Status = cm.Contact.status__c != null ? cm.Contact.status__c : '';
              }
              if(cm.Lead.Id!=null){
                   this.Company = cm.Lead.Company != null ? cm.Lead.Company :'';
              }else if(cm.Contact.Id != null){
                   this.Company = cm.Contact.Company__c !=null ? cm.Contact.Company__c:'';
              }
              if(cm.Lead.Id!=null){
                 this.FirstName = cm.Lead.FirstName !=null ? cm.Lead.FirstName :'';
              }else if(cm.Contact.Id != null){
                this.Company = cm.Contact.FirstName !=null ? cm.Contact.FirstName:'';
              }
              if(cm.Lead.Id != null){
                  this.lastName = cm.Lead.lastName != null ? cm.Lead.lastName : '';
              }else if(cm.Contact.Id != null){
                  this.lastName = cm.Contact.lastName != null ? cm.Contact.lastName : '';
              }
               if(cm.Lead.Id != null){
                  this.City = cm.Lead.City != null ? cm.Lead.City : '';
              }else if(cm.Contact.Id != null){
                  this.City= cm.Contact.City__c != null ? cm.Contact.City__c : '';
              }
              if(cm.Lead.Id != null){
                  this.State = cm.Lead.State != null ? cm.Lead.State : '';
              }else if(cm.Contact.Id != null){
                  this.State= cm.Contact.State__c != null ? cm.Contact.State__c : '';
              }
              if(cm.Lead.Id != null){
                  this.Country = cm.Lead.Country != null ? cm.Lead.Country : '';
              }else if(cm.Contact.Id != null){
                  this.Country= cm.Contact.Country__c != null ? cm.Contact.Country__c : '';
              } 
              if(cm.Lead.Id != null){
                  this.leadSource = cm.Lead.leadSource != null ? cm.Lead.leadSource : '';
              }else if(cm.Contact.Id != null){
                  this.leadSource= cm.Contact.leadSource != null ? cm.Contact.leadSource : '';
              } 
           }
}

}

  • Please mark my answer as correct if I helped solving your problem. Else... what's up still there? :) (read: let us know how it went in the end and we'll help you more if needed) – MLucci Nov 13 '14 at 17:03
1

In your SOQL at the first lines you are using a bind variable ":Lead.Campaign__c", but there is no context variable initialized with that name - you used name "l". Changing that in the SOQL will fix this specific issue.

In the current implementation, the ":Lead." bind variable is leading Apex compiler to the Lead sObject "static class" (not very correct canonical definition of it), of which Campaign__c is a property returning the Schema.SObjectField token reference to the Campaign__c field.

To be more specific: the error tells "hey, you passed me as bind variable a Schema.SObjectField object, while I need to compare it with an Id - review your code!" (we should have a committe for user friendly error messages as such :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.