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

Invalid relationship CampaignMembers for Lead


I am trying to retrieve the Status data from Inner Query but i am getting an error that 

"Content cannot be displayed: Invalid relationship CampaignMembers for Lead" 
Can anyone please help me on this? I have highlighted the line for which i am getting an error.

public with sharing class CampaignView {
public Campaign camp {get; set; }
    public List<MemberWrapper> lMemberWrappers {get; set;}
      public DateTime startDate{get;set;}  
    public CampaignView(ApexPages.StandardController controller) {
        camp = (Campaign)controller.getRecord();
        lMemberWrappers = new List<MemberWrapper>();
     for(Campaign c :[Select ID,(SELECT Id,CampaignId,Status  FROM CampaignMembers where CampaignId =:camp.Id) FROM campaign WHERE id=:camp.Id ]){
              for(Lead ld : CampaignMembers) {
              for (ActivityHistory ah : ld.getSObjects('ActivityHistories')) {
                       lMemberWrappers.add(new MemberWrapper(ld.Phone, ld.getSObject('CampaignMembers').get('Status')));
       private List<Lead> CampaignMembers;
    public List<Lead> getCampaignMembers() {
        CampaignMembers = [Select Id,Name, Phone,MobilePhone,Email, LastModifiedDate,(Select id, Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,Lead.Name,LeadID,ContactID,Lead.Phone,Lead.Email, Lastmodifieddate,Lead.LastmodifiedDate,Status,CampaignId,Campign_ID__c,Lead.MobilePhone  From CampaignMembers where CampaignId =:camp.Id  ),
        (Select Subject, Id,lastModifiedDate From ActivityHistories    order by LastModifiedDate DESC  LIMIT 1  )
        From Lead  where Id IN(select LeadId from campaignMember where campaignId =:camp.Id ) ];
        return CampaignMembers;
        public class MemberWrapper {
        public Object Status {get; set;}
                public String Phone {get; set;}
        public MemberWrapper(String Phone,Object Status ) {
             this.Phone = Phone;
                 this.Status = Status;